<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
    <title>Coverage for cogapp/cogapp.py: 49.34%</title>
    <link rel="stylesheet" href="style.css" type="text/css">
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript" src="jquery.hotkeys.js"></script>
    <script type="text/javascript" src="jquery.isonscreen.js"></script>
    <script type="text/javascript" src="coverage_html.js"></script>
    <script type="text/javascript">
        jQuery(document).ready(coverage.pyfile_ready);
    </script>
</head>
<body class="pyfile">
<div id="header">
    <div class="content">
        <h1>Coverage for <b>cogapp/cogapp.py</b> :
            <span class="pc_cov">49.34%</span>
        </h1>
        <img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
        <h2 class="stats">
            485 statements &nbsp;
            <button type="button" class="run shortkey_r button_toggle_run" title="Toggle lines run">270 run</button>
            <button type="button" class="mis show_mis shortkey_m button_toggle_mis" title="Toggle lines missing">215 missing</button>
            <button type="button" class="exc show_exc shortkey_x button_toggle_exc" title="Toggle lines excluded">1 excluded</button>
            <button type="button" class="par run show_par shortkey_p button_toggle_par" title="Toggle lines partially run">28 partial</button>
        </h2>
    </div>
</div>
<div class="help_panel">
    <img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
    <p class="legend">Hot-keys on this page</p>
    <div>
    <p class="keyhelp">
        <span class="key">r</span>
        <span class="key">m</span>
        <span class="key">x</span>
        <span class="key">p</span> &nbsp; toggle line displays
    </p>
    <p class="keyhelp">
        <span class="key">j</span>
        <span class="key">k</span> &nbsp; next/prev highlighted chunk
    </p>
    <p class="keyhelp">
        <span class="key">0</span> &nbsp; (zero) top of page
    </p>
    <p class="keyhelp">
        <span class="key">1</span> &nbsp; (one) first highlighted chunk
    </p>
    </div>
</div>
<div id="source">
    <p id="t1" class="pln"><span class="n"><a href="#t1">1</a></span><span class="t"><span class="com"># coding: utf8</span>&nbsp;</span><span class="r"></span></p>
    <p id="t2" class="run"><span class="n"><a href="#t2">2</a></span><span class="t"><span class="str">""" Cog content generation tool.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t3" class="pln"><span class="n"><a href="#t3">3</a></span><span class="t"><span class="str">    http://nedbatchelder.com/code/cog</span>&nbsp;</span><span class="r"></span></p>
    <p id="t4" class="pln"><span class="n"><a href="#t4">4</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t5" class="pln"><span class="n"><a href="#t5">5</a></span><span class="t"><span class="str">    Copyright 2004-2019, Ned Batchelder.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t6" class="pln"><span class="n"><a href="#t6">6</a></span><span class="t"><span class="str">"""</span>&nbsp;</span><span class="r"></span></p>
    <p id="t7" class="pln"><span class="n"><a href="#t7">7</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t8" class="run"><span class="n"><a href="#t8">8</a></span><span class="t"><span class="key">from</span> <span class="nam">__future__</span> <span class="key">import</span> <span class="nam">absolute_import</span><span class="op">,</span> <span class="nam">print_function</span>&nbsp;</span><span class="r"></span></p>
    <p id="t9" class="pln"><span class="n"><a href="#t9">9</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t10" class="run"><span class="n"><a href="#t10">10</a></span><span class="t"><span class="key">import</span> <span class="nam">copy</span>&nbsp;</span><span class="r"></span></p>
    <p id="t11" class="run"><span class="n"><a href="#t11">11</a></span><span class="t"><span class="key">import</span> <span class="nam">getopt</span>&nbsp;</span><span class="r"></span></p>
    <p id="t12" class="run"><span class="n"><a href="#t12">12</a></span><span class="t"><span class="key">import</span> <span class="nam">glob</span>&nbsp;</span><span class="r"></span></p>
    <p id="t13" class="run"><span class="n"><a href="#t13">13</a></span><span class="t"><span class="key">import</span> <span class="nam">hashlib</span>&nbsp;</span><span class="r"></span></p>
    <p id="t14" class="run"><span class="n"><a href="#t14">14</a></span><span class="t"><span class="key">import</span> <span class="nam">imp</span>&nbsp;</span><span class="r"></span></p>
    <p id="t15" class="run"><span class="n"><a href="#t15">15</a></span><span class="t"><span class="key">import</span> <span class="nam">linecache</span>&nbsp;</span><span class="r"></span></p>
    <p id="t16" class="run"><span class="n"><a href="#t16">16</a></span><span class="t"><span class="key">import</span> <span class="nam">os</span>&nbsp;</span><span class="r"></span></p>
    <p id="t17" class="run"><span class="n"><a href="#t17">17</a></span><span class="t"><span class="key">import</span> <span class="nam">re</span>&nbsp;</span><span class="r"></span></p>
    <p id="t18" class="run"><span class="n"><a href="#t18">18</a></span><span class="t"><span class="key">import</span> <span class="nam">shlex</span>&nbsp;</span><span class="r"></span></p>
    <p id="t19" class="run"><span class="n"><a href="#t19">19</a></span><span class="t"><span class="key">import</span> <span class="nam">sys</span>&nbsp;</span><span class="r"></span></p>
    <p id="t20" class="run"><span class="n"><a href="#t20">20</a></span><span class="t"><span class="key">import</span> <span class="nam">traceback</span>&nbsp;</span><span class="r"></span></p>
    <p id="t21" class="pln"><span class="n"><a href="#t21">21</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t22" class="run"><span class="n"><a href="#t22">22</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">backward</span> <span class="key">import</span> <span class="nam">PY3</span><span class="op">,</span> <span class="nam">StringIO</span><span class="op">,</span> <span class="nam">string_types</span><span class="op">,</span> <span class="nam">to_bytes</span>&nbsp;</span><span class="r"></span></p>
    <p id="t23" class="pln"><span class="n"><a href="#t23">23</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t24" class="run"><span class="n"><a href="#t24">24</a></span><span class="t"><span class="nam">__all__</span> <span class="op">=</span> <span class="op">[</span><span class="str">'Cog'</span><span class="op">,</span> <span class="str">'CogUsageError'</span><span class="op">,</span> <span class="str">'main'</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t25" class="pln"><span class="n"><a href="#t25">25</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t26" class="run"><span class="n"><a href="#t26">26</a></span><span class="t"><span class="nam">__version__</span> <span class="op">=</span> <span class="str">'3.0.0'</span>&nbsp;</span><span class="r"></span></p>
    <p id="t27" class="pln"><span class="n"><a href="#t27">27</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t28" class="run"><span class="n"><a href="#t28">28</a></span><span class="t"><span class="nam">usage</span> <span class="op">=</span> <span class="str">"""\</span>&nbsp;</span><span class="r"></span></p>
    <p id="t29" class="pln"><span class="n"><a href="#t29">29</a></span><span class="t"><span class="str">cog - generate content with inlined Python code.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t30" class="pln"><span class="n"><a href="#t30">30</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t31" class="pln"><span class="n"><a href="#t31">31</a></span><span class="t"><span class="str">cog [OPTIONS] [INFILE | @FILELIST] ...</span>&nbsp;</span><span class="r"></span></p>
    <p id="t32" class="pln"><span class="n"><a href="#t32">32</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t33" class="pln"><span class="n"><a href="#t33">33</a></span><span class="t"><span class="str">INFILE is the name of an input file, '-' will read from stdin.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t34" class="pln"><span class="n"><a href="#t34">34</a></span><span class="t"><span class="str">FILELIST is the name of a text file containing file names or</span>&nbsp;</span><span class="r"></span></p>
    <p id="t35" class="pln"><span class="n"><a href="#t35">35</a></span><span class="t"><span class="str">    other @FILELISTs.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t36" class="pln"><span class="n"><a href="#t36">36</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t37" class="pln"><span class="n"><a href="#t37">37</a></span><span class="t"><span class="str">OPTIONS:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t38" class="pln"><span class="n"><a href="#t38">38</a></span><span class="t"><span class="str">    -c          Checksum the output to protect it against accidental change.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t39" class="pln"><span class="n"><a href="#t39">39</a></span><span class="t"><span class="str">    -d          Delete the generator code from the output file.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t40" class="pln"><span class="n"><a href="#t40">40</a></span><span class="t"><span class="str">    -D name=val Define a global string available to your generator code.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t41" class="pln"><span class="n"><a href="#t41">41</a></span><span class="t"><span class="str">    -e          Warn if a file has no cog code in it.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t42" class="pln"><span class="n"><a href="#t42">42</a></span><span class="t"><span class="str">    -I PATH     Add PATH to the list of directories for data files and modules.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t43" class="pln"><span class="n"><a href="#t43">43</a></span><span class="t"><span class="str">    -n ENCODING Use ENCODING when reading and writing files.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t44" class="pln"><span class="n"><a href="#t44">44</a></span><span class="t"><span class="str">    -o OUTNAME  Write the output to OUTNAME.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t45" class="pln"><span class="n"><a href="#t45">45</a></span><span class="t"><span class="str">    -p PROLOGUE Prepend the generator source with PROLOGUE. Useful to insert an</span>&nbsp;</span><span class="r"></span></p>
    <p id="t46" class="pln"><span class="n"><a href="#t46">46</a></span><span class="t"><span class="str">                import line. Example: -p "import math"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t47" class="pln"><span class="n"><a href="#t47">47</a></span><span class="t"><span class="str">    -r          Replace the input file with the output.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t48" class="pln"><span class="n"><a href="#t48">48</a></span><span class="t"><span class="str">    -s STRING   Suffix all generated output lines with STRING.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t49" class="pln"><span class="n"><a href="#t49">49</a></span><span class="t"><span class="str">    -U          Write the output with Unix newlines (only LF line-endings).</span>&nbsp;</span><span class="r"></span></p>
    <p id="t50" class="pln"><span class="n"><a href="#t50">50</a></span><span class="t"><span class="str">    -w CMD      Use CMD if the output file needs to be made writable.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t51" class="pln"><span class="n"><a href="#t51">51</a></span><span class="t"><span class="str">                    A %s in the CMD will be filled with the filename.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t52" class="pln"><span class="n"><a href="#t52">52</a></span><span class="t"><span class="str">    -x          Excise all the generated output without running the generators.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t53" class="pln"><span class="n"><a href="#t53">53</a></span><span class="t"><span class="str">    -z          The end-output marker can be omitted, and is assumed at eof.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t54" class="pln"><span class="n"><a href="#t54">54</a></span><span class="t"><span class="str">    -v          Print the version of cog and exit.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t55" class="pln"><span class="n"><a href="#t55">55</a></span><span class="t"><span class="str">    --verbosity=VERBOSITY</span>&nbsp;</span><span class="r"></span></p>
    <p id="t56" class="pln"><span class="n"><a href="#t56">56</a></span><span class="t"><span class="str">                Control the amount of output. 2 (the default) lists all files,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t57" class="pln"><span class="n"><a href="#t57">57</a></span><span class="t"><span class="str">                1 lists only changed files, 0 lists no files.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t58" class="pln"><span class="n"><a href="#t58">58</a></span><span class="t"><span class="str">    --markers='START END END-OUTPUT'</span>&nbsp;</span><span class="r"></span></p>
    <p id="t59" class="pln"><span class="n"><a href="#t59">59</a></span><span class="t"><span class="str">                The patterns surrounding cog inline instructions. Should</span>&nbsp;</span><span class="r"></span></p>
    <p id="t60" class="pln"><span class="n"><a href="#t60">60</a></span><span class="t"><span class="str">                include three values separated by spaces, the start, end,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t61" class="pln"><span class="n"><a href="#t61">61</a></span><span class="t"><span class="str">                and end-output markers. Defaults to '[[[cog ]]] [[[end]]]'.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t62" class="pln"><span class="n"><a href="#t62">62</a></span><span class="t"><span class="str">    -h          Print this help.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t63" class="pln"><span class="n"><a href="#t63">63</a></span><span class="t"><span class="str">"""</span>&nbsp;</span><span class="r"></span></p>
    <p id="t64" class="pln"><span class="n"><a href="#t64">64</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t65" class="pln"><span class="n"><a href="#t65">65</a></span><span class="t"><span class="com"># Other package modules</span>&nbsp;</span><span class="r"></span></p>
    <p id="t66" class="run"><span class="n"><a href="#t66">66</a></span><span class="t"><span class="key">from</span> <span class="op">.</span><span class="nam">whiteutils</span> <span class="key">import</span> <span class="op">*</span>&nbsp;</span><span class="r"></span></p>
    <p id="t67" class="pln"><span class="n"><a href="#t67">67</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t68" class="run"><span class="n"><a href="#t68">68</a></span><span class="t"><span class="key">class</span> <span class="nam">CogError</span><span class="op">(</span><span class="nam">Exception</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t69" class="pln"><span class="n"><a href="#t69">69</a></span><span class="t">    <span class="str">""" Any exception raised by Cog.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t70" class="pln"><span class="n"><a href="#t70">70</a></span><span class="t"><span class="str">    """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t71" class="run"><span class="n"><a href="#t71">71</a></span><span class="t">    <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">msg</span><span class="op">,</span> <span class="nam">file</span><span class="op">=</span><span class="str">''</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t72" class="run"><span class="n"><a href="#t72">72</a></span><span class="t">        <span class="key">if</span> <span class="nam">file</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t73" class="run"><span class="n"><a href="#t73">73</a></span><span class="t">            <span class="nam">Exception</span><span class="op">.</span><span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="str">"%s(%d): %s"</span> <span class="op">%</span> <span class="op">(</span><span class="nam">file</span><span class="op">,</span> <span class="nam">line</span><span class="op">,</span> <span class="nam">msg</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t74" class="pln"><span class="n"><a href="#t74">74</a></span><span class="t">        <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t75" class="run"><span class="n"><a href="#t75">75</a></span><span class="t">            <span class="nam">Exception</span><span class="op">.</span><span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">msg</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t76" class="pln"><span class="n"><a href="#t76">76</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t77" class="run"><span class="n"><a href="#t77">77</a></span><span class="t"><span class="key">class</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="nam">CogError</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t78" class="pln"><span class="n"><a href="#t78">78</a></span><span class="t">    <span class="str">""" An error in usage of command-line arguments in cog.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t79" class="pln"><span class="n"><a href="#t79">79</a></span><span class="t"><span class="str">    """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t80" class="run"><span class="n"><a href="#t80">80</a></span><span class="t">    <span class="key">pass</span>&nbsp;</span><span class="r"></span></p>
    <p id="t81" class="pln"><span class="n"><a href="#t81">81</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t82" class="run"><span class="n"><a href="#t82">82</a></span><span class="t"><span class="key">class</span> <span class="nam">CogInternalError</span><span class="op">(</span><span class="nam">CogError</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t83" class="pln"><span class="n"><a href="#t83">83</a></span><span class="t">    <span class="str">""" An error in the coding of Cog. Should never happen.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t84" class="pln"><span class="n"><a href="#t84">84</a></span><span class="t"><span class="str">    """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t85" class="run"><span class="n"><a href="#t85">85</a></span><span class="t">    <span class="key">pass</span>&nbsp;</span><span class="r"></span></p>
    <p id="t86" class="pln"><span class="n"><a href="#t86">86</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t87" class="run"><span class="n"><a href="#t87">87</a></span><span class="t"><span class="key">class</span> <span class="nam">CogGeneratedError</span><span class="op">(</span><span class="nam">CogError</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t88" class="pln"><span class="n"><a href="#t88">88</a></span><span class="t">    <span class="str">""" An error raised by a user's cog generator.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t89" class="pln"><span class="n"><a href="#t89">89</a></span><span class="t"><span class="str">    """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t90" class="run"><span class="n"><a href="#t90">90</a></span><span class="t">    <span class="key">pass</span>&nbsp;</span><span class="r"></span></p>
    <p id="t91" class="pln"><span class="n"><a href="#t91">91</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t92" class="run"><span class="n"><a href="#t92">92</a></span><span class="t"><span class="key">class</span> <span class="nam">CogUserException</span><span class="op">(</span><span class="nam">CogError</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t93" class="pln"><span class="n"><a href="#t93">93</a></span><span class="t">    <span class="str">""" An exception caught when running a user's cog generator.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t94" class="pln"><span class="n"><a href="#t94">94</a></span><span class="t"><span class="str">        The argument is the traceback message to print.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t95" class="pln"><span class="n"><a href="#t95">95</a></span><span class="t"><span class="str">    """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t96" class="run"><span class="n"><a href="#t96">96</a></span><span class="t">    <span class="key">pass</span>&nbsp;</span><span class="r"></span></p>
    <p id="t97" class="pln"><span class="n"><a href="#t97">97</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t98" class="run"><span class="n"><a href="#t98">98</a></span><span class="t"><span class="key">class</span> <span class="nam">Redirectable</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t99" class="pln"><span class="n"><a href="#t99">99</a></span><span class="t">    <span class="str">""" An object with its own stdout and stderr files.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t100" class="pln"><span class="n"><a href="#t100">100</a></span><span class="t"><span class="str">    """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t101" class="run"><span class="n"><a href="#t101">101</a></span><span class="t">    <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t102" class="run"><span class="n"><a href="#t102">102</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stdout</span>&nbsp;</span><span class="r"></span></p>
    <p id="t103" class="run"><span class="n"><a href="#t103">103</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">stderr</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stderr</span>&nbsp;</span><span class="r"></span></p>
    <p id="t104" class="pln"><span class="n"><a href="#t104">104</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t105" class="run"><span class="n"><a href="#t105">105</a></span><span class="t">    <span class="key">def</span> <span class="nam">setOutput</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">stdout</span><span class="op">=</span><span class="key">None</span><span class="op">,</span> <span class="nam">stderr</span><span class="op">=</span><span class="key">None</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t106" class="pln"><span class="n"><a href="#t106">106</a></span><span class="t">        <span class="str">""" Assign new files for standard out and/or standard error.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t107" class="pln"><span class="n"><a href="#t107">107</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t108" class="par run show_par"><span class="n"><a href="#t108">108</a></span><span class="t">        <span class="key">if</span> <span class="nam">stdout</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">108&#x202F;&#x219B;&#x202F;110</span><span class="annotate long">line 108 didn't jump to line 110, because the condition on line 108 was never false</span></span></p>
    <p id="t109" class="run"><span class="n"><a href="#t109">109</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span> <span class="op">=</span> <span class="nam">stdout</span>&nbsp;</span><span class="r"></span></p>
    <p id="t110" class="par run show_par"><span class="n"><a href="#t110">110</a></span><span class="t">        <span class="key">if</span> <span class="nam">stderr</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">110&#x202F;&#x219B;&#x202F;111</span><span class="annotate long">line 110 didn't jump to line 111, because the condition on line 110 was never true</span></span></p>
    <p id="t111" class="mis show_mis"><span class="n"><a href="#t111">111</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">stderr</span> <span class="op">=</span> <span class="nam">stderr</span>&nbsp;</span><span class="r"></span></p>
    <p id="t112" class="pln"><span class="n"><a href="#t112">112</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t113" class="run"><span class="n"><a href="#t113">113</a></span><span class="t">    <span class="key">def</span> <span class="nam">prout</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="str">"\n"</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t114" class="mis show_mis"><span class="n"><a href="#t114">114</a></span><span class="t">        <span class="nam">print</span><span class="op">(</span><span class="nam">s</span><span class="op">,</span> <span class="nam">file</span><span class="op">=</span><span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="nam">end</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t115" class="pln"><span class="n"><a href="#t115">115</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t116" class="run"><span class="n"><a href="#t116">116</a></span><span class="t">    <span class="key">def</span> <span class="nam">prerr</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="str">"\n"</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t117" class="mis show_mis"><span class="n"><a href="#t117">117</a></span><span class="t">        <span class="nam">print</span><span class="op">(</span><span class="nam">s</span><span class="op">,</span> <span class="nam">file</span><span class="op">=</span><span class="nam">self</span><span class="op">.</span><span class="nam">stderr</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="nam">end</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t118" class="pln"><span class="n"><a href="#t118">118</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t119" class="pln"><span class="n"><a href="#t119">119</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t120" class="run"><span class="n"><a href="#t120">120</a></span><span class="t"><span class="key">class</span> <span class="nam">CogGenerator</span><span class="op">(</span><span class="nam">Redirectable</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t121" class="pln"><span class="n"><a href="#t121">121</a></span><span class="t">    <span class="str">""" A generator pulled from a source file.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t122" class="pln"><span class="n"><a href="#t122">122</a></span><span class="t"><span class="str">    """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t123" class="run"><span class="n"><a href="#t123">123</a></span><span class="t">    <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">options</span><span class="op">=</span><span class="key">None</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t124" class="run"><span class="n"><a href="#t124">124</a></span><span class="t">        <span class="nam">Redirectable</span><span class="op">.</span><span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t125" class="run"><span class="n"><a href="#t125">125</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">markers</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t126" class="run"><span class="n"><a href="#t126">126</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">lines</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t127" class="run"><span class="n"><a href="#t127">127</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">options</span> <span class="op">=</span> <span class="nam">options</span> <span class="key">or</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t128" class="pln"><span class="n"><a href="#t128">128</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t129" class="run"><span class="n"><a href="#t129">129</a></span><span class="t">    <span class="key">def</span> <span class="nam">parseMarker</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">l</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t130" class="run"><span class="n"><a href="#t130">130</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">markers</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t131" class="pln"><span class="n"><a href="#t131">131</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t132" class="run"><span class="n"><a href="#t132">132</a></span><span class="t">    <span class="key">def</span> <span class="nam">parseLine</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">l</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t133" class="run"><span class="n"><a href="#t133">133</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">lines</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">l</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="str">'\n'</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t134" class="pln"><span class="n"><a href="#t134">134</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t135" class="run"><span class="n"><a href="#t135">135</a></span><span class="t">    <span class="key">def</span> <span class="nam">getCode</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t136" class="pln"><span class="n"><a href="#t136">136</a></span><span class="t">        <span class="str">""" Extract the executable Python code from the generator.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t137" class="pln"><span class="n"><a href="#t137">137</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t138" class="pln"><span class="n"><a href="#t138">138</a></span><span class="t">        <span class="com"># If the markers and lines all have the same prefix</span>&nbsp;</span><span class="r"></span></p>
    <p id="t139" class="pln"><span class="n"><a href="#t139">139</a></span><span class="t">        <span class="com"># (end-of-line comment chars, for example),</span>&nbsp;</span><span class="r"></span></p>
    <p id="t140" class="pln"><span class="n"><a href="#t140">140</a></span><span class="t">        <span class="com"># then remove it from all the lines.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t141" class="run"><span class="n"><a href="#t141">141</a></span><span class="t">        <span class="nam">prefIn</span> <span class="op">=</span> <span class="nam">commonPrefix</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">markers</span> <span class="op">+</span> <span class="nam">self</span><span class="op">.</span><span class="nam">lines</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t142" class="run"><span class="n"><a href="#t142">142</a></span><span class="t">        <span class="key">if</span> <span class="nam">prefIn</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t143" class="run"><span class="n"><a href="#t143">143</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">markers</span> <span class="op">=</span> <span class="op">[</span> <span class="nam">l</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="nam">prefIn</span><span class="op">,</span> <span class="str">''</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span> <span class="key">for</span> <span class="nam">l</span> <span class="key">in</span> <span class="nam">self</span><span class="op">.</span><span class="nam">markers</span> <span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t144" class="run"><span class="n"><a href="#t144">144</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">lines</span> <span class="op">=</span> <span class="op">[</span> <span class="nam">l</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="nam">prefIn</span><span class="op">,</span> <span class="str">''</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span> <span class="key">for</span> <span class="nam">l</span> <span class="key">in</span> <span class="nam">self</span><span class="op">.</span><span class="nam">lines</span> <span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t145" class="pln"><span class="n"><a href="#t145">145</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t146" class="run"><span class="n"><a href="#t146">146</a></span><span class="t">        <span class="key">return</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">lines</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t147" class="pln"><span class="n"><a href="#t147">147</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t148" class="run"><span class="n"><a href="#t148">148</a></span><span class="t">    <span class="key">def</span> <span class="nam">evaluate</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">cog</span><span class="op">,</span> <span class="nam">globals</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t149" class="pln"><span class="n"><a href="#t149">149</a></span><span class="t">        <span class="com"># figure out the right whitespace prefix for the output</span>&nbsp;</span><span class="r"></span></p>
    <p id="t150" class="run"><span class="n"><a href="#t150">150</a></span><span class="t">        <span class="nam">prefOut</span> <span class="op">=</span> <span class="nam">whitePrefix</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">markers</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t151" class="pln"><span class="n"><a href="#t151">151</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t152" class="run"><span class="n"><a href="#t152">152</a></span><span class="t">        <span class="nam">intext</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">getCode</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t153" class="run"><span class="n"><a href="#t153">153</a></span><span class="t">        <span class="key">if</span> <span class="key">not</span> <span class="nam">intext</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t154" class="run"><span class="n"><a href="#t154">154</a></span><span class="t">            <span class="key">return</span> <span class="str">''</span>&nbsp;</span><span class="r"></span></p>
    <p id="t155" class="pln"><span class="n"><a href="#t155">155</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t156" class="run"><span class="n"><a href="#t156">156</a></span><span class="t">        <span class="nam">prologue</span> <span class="op">=</span> <span class="str">"import "</span> <span class="op">+</span> <span class="nam">cog</span><span class="op">.</span><span class="nam">cogmodulename</span> <span class="op">+</span> <span class="str">" as cog\n"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t157" class="par run show_par"><span class="n"><a href="#t157">157</a></span><span class="t">        <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sPrologue</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">157&#x202F;&#x219B;&#x202F;158</span><span class="annotate long">line 157 didn't jump to line 158, because the condition on line 157 was never true</span></span></p>
    <p id="t158" class="mis show_mis"><span class="n"><a href="#t158">158</a></span><span class="t">            <span class="nam">prologue</span> <span class="op">+=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sPrologue</span> <span class="op">+</span> <span class="str">'\n'</span>&nbsp;</span><span class="r"></span></p>
    <p id="t159" class="run"><span class="n"><a href="#t159">159</a></span><span class="t">        <span class="nam">code</span> <span class="op">=</span> <span class="nam">compile</span><span class="op">(</span><span class="nam">prologue</span> <span class="op">+</span> <span class="nam">intext</span><span class="op">,</span> <span class="nam">str</span><span class="op">(</span><span class="nam">fname</span><span class="op">)</span><span class="op">,</span> <span class="str">'exec'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t160" class="pln"><span class="n"><a href="#t160">160</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t161" class="pln"><span class="n"><a href="#t161">161</a></span><span class="t">        <span class="com"># Make sure the "cog" module has our state.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t162" class="run"><span class="n"><a href="#t162">162</a></span><span class="t">        <span class="nam">cog</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">msg</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">msg</span>&nbsp;</span><span class="r"></span></p>
    <p id="t163" class="run"><span class="n"><a href="#t163">163</a></span><span class="t">        <span class="nam">cog</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">out</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">out</span>&nbsp;</span><span class="r"></span></p>
    <p id="t164" class="run"><span class="n"><a href="#t164">164</a></span><span class="t">        <span class="nam">cog</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">outl</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">outl</span>&nbsp;</span><span class="r"></span></p>
    <p id="t165" class="run"><span class="n"><a href="#t165">165</a></span><span class="t">        <span class="nam">cog</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">error</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">error</span>&nbsp;</span><span class="r"></span></p>
    <p id="t166" class="pln"><span class="n"><a href="#t166">166</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t167" class="run"><span class="n"><a href="#t167">167</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span> <span class="op">=</span> <span class="str">''</span>&nbsp;</span><span class="r"></span></p>
    <p id="t168" class="run"><span class="n"><a href="#t168">168</a></span><span class="t">        <span class="key">try</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t169" class="run"><span class="n"><a href="#t169">169</a></span><span class="t">            <span class="nam">eval</span><span class="op">(</span><span class="nam">code</span><span class="op">,</span> <span class="nam">globals</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t170" class="par run show_par"><span class="n"><a href="#t170">170</a></span><span class="t">        <span class="key">except</span> <span class="nam">CogError</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">170&#x202F;&#x219B;&#x202F;171</span><span class="annotate long">line 170 didn't jump to line 171, because the exception caught by line 170 didn't happen</span></span></p>
    <p id="t171" class="mis show_mis"><span class="n"><a href="#t171">171</a></span><span class="t">            <span class="key">raise</span>&nbsp;</span><span class="r"></span></p>
    <p id="t172" class="run"><span class="n"><a href="#t172">172</a></span><span class="t">        <span class="key">except</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t173" class="run"><span class="n"><a href="#t173">173</a></span><span class="t">            <span class="nam">typ</span><span class="op">,</span> <span class="nam">err</span><span class="op">,</span> <span class="nam">tb</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">exc_info</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t174" class="run"><span class="n"><a href="#t174">174</a></span><span class="t">            <span class="nam">frames</span> <span class="op">=</span> <span class="op">(</span><span class="nam">tuple</span><span class="op">(</span><span class="nam">fr</span><span class="op">)</span> <span class="key">for</span> <span class="nam">fr</span> <span class="key">in</span> <span class="nam">traceback</span><span class="op">.</span><span class="nam">extract_tb</span><span class="op">(</span><span class="nam">tb</span><span class="op">.</span><span class="nam">tb_next</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t175" class="run"><span class="n"><a href="#t175">175</a></span><span class="t">            <span class="nam">frames</span> <span class="op">=</span> <span class="nam">find_cog_source</span><span class="op">(</span><span class="nam">frames</span><span class="op">,</span> <span class="nam">prologue</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t176" class="run"><span class="n"><a href="#t176">176</a></span><span class="t">            <span class="nam">msg</span> <span class="op">=</span> <span class="str">""</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">traceback</span><span class="op">.</span><span class="nam">format_list</span><span class="op">(</span><span class="nam">frames</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t177" class="run"><span class="n"><a href="#t177">177</a></span><span class="t">            <span class="nam">msg</span> <span class="op">+=</span> <span class="str">"{}: {}"</span><span class="op">.</span><span class="nam">format</span><span class="op">(</span><span class="nam">typ</span><span class="op">.</span><span class="nam">__name__</span><span class="op">,</span> <span class="nam">err</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t178" class="run"><span class="n"><a href="#t178">178</a></span><span class="t">            <span class="key">raise</span> <span class="nam">CogUserException</span><span class="op">(</span><span class="nam">msg</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t179" class="pln"><span class="n"><a href="#t179">179</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t180" class="pln"><span class="n"><a href="#t180">180</a></span><span class="t">        <span class="com"># We need to make sure that the last line in the output</span>&nbsp;</span><span class="r"></span></p>
    <p id="t181" class="pln"><span class="n"><a href="#t181">181</a></span><span class="t">        <span class="com"># ends with a newline, or it will be joined to the</span>&nbsp;</span><span class="r"></span></p>
    <p id="t182" class="pln"><span class="n"><a href="#t182">182</a></span><span class="t">        <span class="com"># end-output line, ruining cog's idempotency.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t183" class="run"><span class="n"><a href="#t183">183</a></span><span class="t">        <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span> <span class="key">and</span> <span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span><span class="op">[</span><span class="op">-</span><span class="num">1</span><span class="op">]</span> <span class="op">!=</span> <span class="str">'\n'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t184" class="run"><span class="n"><a href="#t184">184</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span> <span class="op">+=</span> <span class="str">'\n'</span>&nbsp;</span><span class="r"></span></p>
    <p id="t185" class="pln"><span class="n"><a href="#t185">185</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t186" class="run"><span class="n"><a href="#t186">186</a></span><span class="t">        <span class="key">return</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span><span class="op">,</span> <span class="nam">prefOut</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t187" class="pln"><span class="n"><a href="#t187">187</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t188" class="run"><span class="n"><a href="#t188">188</a></span><span class="t">    <span class="key">def</span> <span class="nam">msg</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t189" class="mis show_mis"><span class="n"><a href="#t189">189</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">"Message: "</span><span class="op">+</span><span class="nam">s</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t190" class="pln"><span class="n"><a href="#t190">190</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t191" class="run"><span class="n"><a href="#t191">191</a></span><span class="t">    <span class="key">def</span> <span class="nam">out</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sOut</span><span class="op">=</span><span class="str">''</span><span class="op">,</span> <span class="nam">dedent</span><span class="op">=</span><span class="key">False</span><span class="op">,</span> <span class="nam">trimblanklines</span><span class="op">=</span><span class="key">False</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t192" class="pln"><span class="n"><a href="#t192">192</a></span><span class="t">        <span class="str">""" The cog.out function.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t193" class="pln"><span class="n"><a href="#t193">193</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t194" class="run"><span class="n"><a href="#t194">194</a></span><span class="t">        <span class="key">if</span> <span class="nam">trimblanklines</span> <span class="key">and</span> <span class="op">(</span><span class="str">'\n'</span> <span class="key">in</span> <span class="nam">sOut</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t195" class="run"><span class="n"><a href="#t195">195</a></span><span class="t">            <span class="nam">lines</span> <span class="op">=</span> <span class="nam">sOut</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="str">'\n'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t196" class="run"><span class="n"><a href="#t196">196</a></span><span class="t">            <span class="key">if</span> <span class="nam">lines</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="str">''</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t197" class="run"><span class="n"><a href="#t197">197</a></span><span class="t">                <span class="key">del</span> <span class="nam">lines</span><span class="op">[</span><span class="num">0</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t198" class="run"><span class="n"><a href="#t198">198</a></span><span class="t">            <span class="key">if</span> <span class="nam">lines</span> <span class="key">and</span> <span class="nam">lines</span><span class="op">[</span><span class="op">-</span><span class="num">1</span><span class="op">]</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="str">''</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t199" class="run"><span class="n"><a href="#t199">199</a></span><span class="t">                <span class="key">del</span> <span class="nam">lines</span><span class="op">[</span><span class="op">-</span><span class="num">1</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t200" class="run"><span class="n"><a href="#t200">200</a></span><span class="t">            <span class="nam">sOut</span> <span class="op">=</span> <span class="str">'\n'</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">lines</span><span class="op">)</span><span class="op">+</span><span class="str">'\n'</span>&nbsp;</span><span class="r"></span></p>
    <p id="t201" class="run"><span class="n"><a href="#t201">201</a></span><span class="t">        <span class="key">if</span> <span class="nam">dedent</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t202" class="run"><span class="n"><a href="#t202">202</a></span><span class="t">            <span class="nam">sOut</span> <span class="op">=</span> <span class="nam">reindentBlock</span><span class="op">(</span><span class="nam">sOut</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t203" class="run"><span class="n"><a href="#t203">203</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">outstring</span> <span class="op">+=</span> <span class="nam">sOut</span>&nbsp;</span><span class="r"></span></p>
    <p id="t204" class="pln"><span class="n"><a href="#t204">204</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t205" class="run"><span class="n"><a href="#t205">205</a></span><span class="t">    <span class="key">def</span> <span class="nam">outl</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sOut</span><span class="op">=</span><span class="str">''</span><span class="op">,</span> <span class="op">**</span><span class="nam">kw</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t206" class="pln"><span class="n"><a href="#t206">206</a></span><span class="t">        <span class="str">""" The cog.outl function.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t207" class="pln"><span class="n"><a href="#t207">207</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t208" class="run"><span class="n"><a href="#t208">208</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">out</span><span class="op">(</span><span class="nam">sOut</span><span class="op">,</span> <span class="op">**</span><span class="nam">kw</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t209" class="run"><span class="n"><a href="#t209">209</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">out</span><span class="op">(</span><span class="str">'\n'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t210" class="pln"><span class="n"><a href="#t210">210</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t211" class="run"><span class="n"><a href="#t211">211</a></span><span class="t">    <span class="key">def</span> <span class="nam">error</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">msg</span><span class="op">=</span><span class="str">'Error raised by cog generator.'</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t212" class="pln"><span class="n"><a href="#t212">212</a></span><span class="t">        <span class="str">""" The cog.error function.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t213" class="pln"><span class="n"><a href="#t213">213</a></span><span class="t"><span class="str">            Instead of raising standard python errors, cog generators can use</span>&nbsp;</span><span class="r"></span></p>
    <p id="t214" class="pln"><span class="n"><a href="#t214">214</a></span><span class="t"><span class="str">            this function.  It will display the error without a scary Python</span>&nbsp;</span><span class="r"></span></p>
    <p id="t215" class="pln"><span class="n"><a href="#t215">215</a></span><span class="t"><span class="str">            traceback.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t216" class="pln"><span class="n"><a href="#t216">216</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t217" class="mis show_mis"><span class="n"><a href="#t217">217</a></span><span class="t">        <span class="key">raise</span> <span class="nam">CogGeneratedError</span><span class="op">(</span><span class="nam">msg</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t218" class="pln"><span class="n"><a href="#t218">218</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t219" class="pln"><span class="n"><a href="#t219">219</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t220" class="run"><span class="n"><a href="#t220">220</a></span><span class="t"><span class="key">class</span> <span class="nam">NumberedFileReader</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t221" class="pln"><span class="n"><a href="#t221">221</a></span><span class="t">    <span class="str">""" A decorator for files that counts the readline()'s called.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t222" class="pln"><span class="n"><a href="#t222">222</a></span><span class="t"><span class="str">    """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t223" class="run"><span class="n"><a href="#t223">223</a></span><span class="t">    <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">f</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t224" class="run"><span class="n"><a href="#t224">224</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">f</span> <span class="op">=</span> <span class="nam">f</span>&nbsp;</span><span class="r"></span></p>
    <p id="t225" class="run"><span class="n"><a href="#t225">225</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">n</span> <span class="op">=</span> <span class="num">0</span>&nbsp;</span><span class="r"></span></p>
    <p id="t226" class="pln"><span class="n"><a href="#t226">226</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t227" class="run"><span class="n"><a href="#t227">227</a></span><span class="t">    <span class="key">def</span> <span class="nam">readline</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t228" class="run"><span class="n"><a href="#t228">228</a></span><span class="t">        <span class="nam">l</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">f</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t229" class="run"><span class="n"><a href="#t229">229</a></span><span class="t">        <span class="key">if</span> <span class="nam">l</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t230" class="run"><span class="n"><a href="#t230">230</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">n</span> <span class="op">+=</span> <span class="num">1</span>&nbsp;</span><span class="r"></span></p>
    <p id="t231" class="run"><span class="n"><a href="#t231">231</a></span><span class="t">        <span class="key">return</span> <span class="nam">l</span>&nbsp;</span><span class="r"></span></p>
    <p id="t232" class="pln"><span class="n"><a href="#t232">232</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t233" class="run"><span class="n"><a href="#t233">233</a></span><span class="t">    <span class="key">def</span> <span class="nam">linenumber</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t234" class="run"><span class="n"><a href="#t234">234</a></span><span class="t">        <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">n</span>&nbsp;</span><span class="r"></span></p>
    <p id="t235" class="pln"><span class="n"><a href="#t235">235</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t236" class="pln"><span class="n"><a href="#t236">236</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t237" class="run"><span class="n"><a href="#t237">237</a></span><span class="t"><span class="key">class</span> <span class="nam">CogOptions</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t238" class="pln"><span class="n"><a href="#t238">238</a></span><span class="t">    <span class="str">""" Options for a run of cog.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t239" class="pln"><span class="n"><a href="#t239">239</a></span><span class="t"><span class="str">    """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t240" class="run"><span class="n"><a href="#t240">240</a></span><span class="t">    <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t241" class="pln"><span class="n"><a href="#t241">241</a></span><span class="t">        <span class="com"># Defaults for argument values.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t242" class="run"><span class="n"><a href="#t242">242</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">args</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t243" class="run"><span class="n"><a href="#t243">243</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">includePath</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t244" class="run"><span class="n"><a href="#t244">244</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">defines</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span>&nbsp;</span><span class="r"></span></p>
    <p id="t245" class="run"><span class="n"><a href="#t245">245</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">bShowVersion</span> <span class="op">=</span> <span class="key">False</span>&nbsp;</span><span class="r"></span></p>
    <p id="t246" class="run"><span class="n"><a href="#t246">246</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">sMakeWritableCmd</span> <span class="op">=</span> <span class="key">None</span>&nbsp;</span><span class="r"></span></p>
    <p id="t247" class="run"><span class="n"><a href="#t247">247</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">bReplace</span> <span class="op">=</span> <span class="key">False</span>&nbsp;</span><span class="r"></span></p>
    <p id="t248" class="run"><span class="n"><a href="#t248">248</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">bNoGenerate</span> <span class="op">=</span> <span class="key">False</span>&nbsp;</span><span class="r"></span></p>
    <p id="t249" class="run"><span class="n"><a href="#t249">249</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">sOutputName</span> <span class="op">=</span> <span class="key">None</span>&nbsp;</span><span class="r"></span></p>
    <p id="t250" class="run"><span class="n"><a href="#t250">250</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">bWarnEmpty</span> <span class="op">=</span> <span class="key">False</span>&nbsp;</span><span class="r"></span></p>
    <p id="t251" class="run"><span class="n"><a href="#t251">251</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">bHashOutput</span> <span class="op">=</span> <span class="key">False</span>&nbsp;</span><span class="r"></span></p>
    <p id="t252" class="run"><span class="n"><a href="#t252">252</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">bDeleteCode</span> <span class="op">=</span> <span class="key">False</span>&nbsp;</span><span class="r"></span></p>
    <p id="t253" class="run"><span class="n"><a href="#t253">253</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">bEofCanBeEnd</span> <span class="op">=</span> <span class="key">False</span>&nbsp;</span><span class="r"></span></p>
    <p id="t254" class="run"><span class="n"><a href="#t254">254</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">sSuffix</span> <span class="op">=</span> <span class="key">None</span>&nbsp;</span><span class="r"></span></p>
    <p id="t255" class="run"><span class="n"><a href="#t255">255</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">bNewlines</span> <span class="op">=</span> <span class="key">False</span>&nbsp;</span><span class="r"></span></p>
    <p id="t256" class="run"><span class="n"><a href="#t256">256</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">sBeginSpec</span> <span class="op">=</span> <span class="str">'[[[cog'</span>&nbsp;</span><span class="r"></span></p>
    <p id="t257" class="run"><span class="n"><a href="#t257">257</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">sEndSpec</span> <span class="op">=</span> <span class="str">']]]'</span>&nbsp;</span><span class="r"></span></p>
    <p id="t258" class="run"><span class="n"><a href="#t258">258</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">sEndOutput</span> <span class="op">=</span> <span class="str">'[[[end]]]'</span>&nbsp;</span><span class="r"></span></p>
    <p id="t259" class="run"><span class="n"><a href="#t259">259</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">sEncoding</span> <span class="op">=</span> <span class="str">"utf-8"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t260" class="run"><span class="n"><a href="#t260">260</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">verbosity</span> <span class="op">=</span> <span class="num">2</span>&nbsp;</span><span class="r"></span></p>
    <p id="t261" class="run"><span class="n"><a href="#t261">261</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">sPrologue</span> <span class="op">=</span> <span class="str">''</span>&nbsp;</span><span class="r"></span></p>
    <p id="t262" class="pln"><span class="n"><a href="#t262">262</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t263" class="run"><span class="n"><a href="#t263">263</a></span><span class="t">    <span class="key">def</span> <span class="nam">__eq__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">other</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t264" class="pln"><span class="n"><a href="#t264">264</a></span><span class="t">        <span class="str">""" Comparison operator for tests to use.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t265" class="pln"><span class="n"><a href="#t265">265</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t266" class="mis show_mis"><span class="n"><a href="#t266">266</a></span><span class="t">        <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">__dict__</span> <span class="op">==</span> <span class="nam">other</span><span class="op">.</span><span class="nam">__dict__</span>&nbsp;</span><span class="r"></span></p>
    <p id="t267" class="pln"><span class="n"><a href="#t267">267</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t268" class="run"><span class="n"><a href="#t268">268</a></span><span class="t">    <span class="key">def</span> <span class="nam">clone</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t269" class="pln"><span class="n"><a href="#t269">269</a></span><span class="t">        <span class="str">""" Make a clone of these options, for further refinement.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t270" class="pln"><span class="n"><a href="#t270">270</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t271" class="mis show_mis"><span class="n"><a href="#t271">271</a></span><span class="t">        <span class="key">return</span> <span class="nam">copy</span><span class="op">.</span><span class="nam">deepcopy</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t272" class="pln"><span class="n"><a href="#t272">272</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t273" class="run"><span class="n"><a href="#t273">273</a></span><span class="t">    <span class="key">def</span> <span class="nam">addToIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">dirs</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t274" class="pln"><span class="n"><a href="#t274">274</a></span><span class="t">        <span class="str">""" Add directories to the include path.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t275" class="pln"><span class="n"><a href="#t275">275</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t276" class="mis show_mis"><span class="n"><a href="#t276">276</a></span><span class="t">        <span class="nam">dirs</span> <span class="op">=</span> <span class="nam">dirs</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">pathsep</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t277" class="mis show_mis"><span class="n"><a href="#t277">277</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">includePath</span><span class="op">.</span><span class="nam">extend</span><span class="op">(</span><span class="nam">dirs</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t278" class="pln"><span class="n"><a href="#t278">278</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t279" class="run"><span class="n"><a href="#t279">279</a></span><span class="t">    <span class="key">def</span> <span class="nam">parseArgs</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">argv</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t280" class="pln"><span class="n"><a href="#t280">280</a></span><span class="t">        <span class="com"># Parse the command line arguments.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t281" class="mis show_mis"><span class="n"><a href="#t281">281</a></span><span class="t">        <span class="key">try</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t282" class="mis show_mis"><span class="n"><a href="#t282">282</a></span><span class="t">            <span class="nam">opts</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">args</span> <span class="op">=</span> <span class="nam">getopt</span><span class="op">.</span><span class="nam">getopt</span><span class="op">(</span>&nbsp;</span><span class="r"></span></p>
    <p id="t283" class="pln"><span class="n"><a href="#t283">283</a></span><span class="t">                <span class="nam">argv</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t284" class="pln"><span class="n"><a href="#t284">284</a></span><span class="t">                <span class="str">'cdD:eI:n:o:rs:p:Uvw:xz'</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t285" class="pln"><span class="n"><a href="#t285">285</a></span><span class="t">                <span class="op">[</span>&nbsp;</span><span class="r"></span></p>
    <p id="t286" class="pln"><span class="n"><a href="#t286">286</a></span><span class="t">                    <span class="str">'markers='</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t287" class="pln"><span class="n"><a href="#t287">287</a></span><span class="t">                    <span class="str">'verbosity='</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t288" class="pln"><span class="n"><a href="#t288">288</a></span><span class="t">                <span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t289" class="pln"><span class="n"><a href="#t289">289</a></span><span class="t">            <span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t290" class="mis show_mis"><span class="n"><a href="#t290">290</a></span><span class="t">        <span class="key">except</span> <span class="nam">getopt</span><span class="op">.</span><span class="nam">error</span> <span class="key">as</span> <span class="nam">msg</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t291" class="mis show_mis"><span class="n"><a href="#t291">291</a></span><span class="t">            <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="nam">msg</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t292" class="pln"><span class="n"><a href="#t292">292</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t293" class="pln"><span class="n"><a href="#t293">293</a></span><span class="t">        <span class="com"># Handle the command line arguments.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t294" class="mis show_mis"><span class="n"><a href="#t294">294</a></span><span class="t">        <span class="key">for</span> <span class="nam">o</span><span class="op">,</span> <span class="nam">a</span> <span class="key">in</span> <span class="nam">opts</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t295" class="mis show_mis"><span class="n"><a href="#t295">295</a></span><span class="t">            <span class="key">if</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-c'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t296" class="mis show_mis"><span class="n"><a href="#t296">296</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">bHashOutput</span> <span class="op">=</span> <span class="key">True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t297" class="mis show_mis"><span class="n"><a href="#t297">297</a></span><span class="t">            <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-d'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t298" class="mis show_mis"><span class="n"><a href="#t298">298</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">bDeleteCode</span> <span class="op">=</span> <span class="key">True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t299" class="mis show_mis"><span class="n"><a href="#t299">299</a></span><span class="t">            <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-D'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t300" class="mis show_mis"><span class="n"><a href="#t300">300</a></span><span class="t">                <span class="key">if</span> <span class="nam">a</span><span class="op">.</span><span class="nam">count</span><span class="op">(</span><span class="str">'='</span><span class="op">)</span> <span class="op">&lt;</span> <span class="num">1</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t301" class="mis show_mis"><span class="n"><a href="#t301">301</a></span><span class="t">                    <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="str">"-D takes a name=value argument"</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t302" class="mis show_mis"><span class="n"><a href="#t302">302</a></span><span class="t">                <span class="nam">name</span><span class="op">,</span> <span class="nam">value</span> <span class="op">=</span> <span class="nam">a</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="str">'='</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t303" class="mis show_mis"><span class="n"><a href="#t303">303</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">defines</span><span class="op">[</span><span class="nam">name</span><span class="op">]</span> <span class="op">=</span> <span class="nam">value</span>&nbsp;</span><span class="r"></span></p>
    <p id="t304" class="mis show_mis"><span class="n"><a href="#t304">304</a></span><span class="t">            <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-e'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t305" class="mis show_mis"><span class="n"><a href="#t305">305</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">bWarnEmpty</span> <span class="op">=</span> <span class="key">True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t306" class="mis show_mis"><span class="n"><a href="#t306">306</a></span><span class="t">            <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-I'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t307" class="mis show_mis"><span class="n"><a href="#t307">307</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">addToIncludePath</span><span class="op">(</span><span class="nam">a</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t308" class="mis show_mis"><span class="n"><a href="#t308">308</a></span><span class="t">            <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-n'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t309" class="mis show_mis"><span class="n"><a href="#t309">309</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">sEncoding</span> <span class="op">=</span> <span class="nam">a</span>&nbsp;</span><span class="r"></span></p>
    <p id="t310" class="mis show_mis"><span class="n"><a href="#t310">310</a></span><span class="t">            <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-o'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t311" class="mis show_mis"><span class="n"><a href="#t311">311</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">sOutputName</span> <span class="op">=</span> <span class="nam">a</span>&nbsp;</span><span class="r"></span></p>
    <p id="t312" class="mis show_mis"><span class="n"><a href="#t312">312</a></span><span class="t">            <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-r'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t313" class="mis show_mis"><span class="n"><a href="#t313">313</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">bReplace</span> <span class="op">=</span> <span class="key">True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t314" class="mis show_mis"><span class="n"><a href="#t314">314</a></span><span class="t">            <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-s'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t315" class="mis show_mis"><span class="n"><a href="#t315">315</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">sSuffix</span> <span class="op">=</span> <span class="nam">a</span>&nbsp;</span><span class="r"></span></p>
    <p id="t316" class="mis show_mis"><span class="n"><a href="#t316">316</a></span><span class="t">            <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-p'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t317" class="mis show_mis"><span class="n"><a href="#t317">317</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">sPrologue</span> <span class="op">=</span> <span class="nam">a</span>&nbsp;</span><span class="r"></span></p>
    <p id="t318" class="mis show_mis"><span class="n"><a href="#t318">318</a></span><span class="t">            <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-U'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t319" class="mis show_mis"><span class="n"><a href="#t319">319</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">bNewlines</span> <span class="op">=</span> <span class="key">True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t320" class="mis show_mis"><span class="n"><a href="#t320">320</a></span><span class="t">            <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-v'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t321" class="mis show_mis"><span class="n"><a href="#t321">321</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">bShowVersion</span> <span class="op">=</span> <span class="key">True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t322" class="mis show_mis"><span class="n"><a href="#t322">322</a></span><span class="t">            <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-w'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t323" class="mis show_mis"><span class="n"><a href="#t323">323</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">sMakeWritableCmd</span> <span class="op">=</span> <span class="nam">a</span>&nbsp;</span><span class="r"></span></p>
    <p id="t324" class="mis show_mis"><span class="n"><a href="#t324">324</a></span><span class="t">            <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-x'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t325" class="mis show_mis"><span class="n"><a href="#t325">325</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">bNoGenerate</span> <span class="op">=</span> <span class="key">True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t326" class="mis show_mis"><span class="n"><a href="#t326">326</a></span><span class="t">            <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'-z'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t327" class="mis show_mis"><span class="n"><a href="#t327">327</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">bEofCanBeEnd</span> <span class="op">=</span> <span class="key">True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t328" class="mis show_mis"><span class="n"><a href="#t328">328</a></span><span class="t">            <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'--markers'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t329" class="mis show_mis"><span class="n"><a href="#t329">329</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">_parse_markers</span><span class="op">(</span><span class="nam">a</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t330" class="mis show_mis"><span class="n"><a href="#t330">330</a></span><span class="t">            <span class="key">elif</span> <span class="nam">o</span> <span class="op">==</span> <span class="str">'--verbosity'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t331" class="mis show_mis"><span class="n"><a href="#t331">331</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">verbosity</span> <span class="op">=</span> <span class="nam">int</span><span class="op">(</span><span class="nam">a</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t332" class="pln"><span class="n"><a href="#t332">332</a></span><span class="t">            <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t333" class="pln"><span class="n"><a href="#t333">333</a></span><span class="t">                <span class="com"># Since getopt.getopt is given a list of possible flags,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t334" class="pln"><span class="n"><a href="#t334">334</a></span><span class="t">                <span class="com"># this is an internal error.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t335" class="exc show_exc"><span class="n"><a href="#t335">335</a></span><span class="t">                <span class="key">raise</span> <span class="nam">CogInternalError</span><span class="op">(</span><span class="str">"Don't understand argument %s"</span> <span class="op">%</span> <span class="nam">o</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t336" class="pln"><span class="n"><a href="#t336">336</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t337" class="run"><span class="n"><a href="#t337">337</a></span><span class="t">    <span class="key">def</span> <span class="nam">_parse_markers</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">val</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t338" class="mis show_mis"><span class="n"><a href="#t338">338</a></span><span class="t">        <span class="key">try</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t339" class="mis show_mis"><span class="n"><a href="#t339">339</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">sEndSpec</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">sEndOutput</span> <span class="op">=</span> <span class="nam">val</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="str">' '</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t340" class="mis show_mis"><span class="n"><a href="#t340">340</a></span><span class="t">        <span class="key">except</span> <span class="nam">ValueError</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t341" class="mis show_mis"><span class="n"><a href="#t341">341</a></span><span class="t">            <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span>&nbsp;</span><span class="r"></span></p>
    <p id="t342" class="pln"><span class="n"><a href="#t342">342</a></span><span class="t">                <span class="str">'--markers requires 3 values separated by spaces, could not parse %r'</span> <span class="op">%</span> <span class="nam">val</span>&nbsp;</span><span class="r"></span></p>
    <p id="t343" class="pln"><span class="n"><a href="#t343">343</a></span><span class="t">            <span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t344" class="pln"><span class="n"><a href="#t344">344</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t345" class="run"><span class="n"><a href="#t345">345</a></span><span class="t">    <span class="key">def</span> <span class="nam">validate</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t346" class="pln"><span class="n"><a href="#t346">346</a></span><span class="t">        <span class="str">""" Does nothing if everything is OK, raises CogError's if it's not.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t347" class="pln"><span class="n"><a href="#t347">347</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t348" class="mis show_mis"><span class="n"><a href="#t348">348</a></span><span class="t">        <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">bReplace</span> <span class="key">and</span> <span class="nam">self</span><span class="op">.</span><span class="nam">bDeleteCode</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t349" class="mis show_mis"><span class="n"><a href="#t349">349</a></span><span class="t">            <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="str">"Can't use -d with -r (or you would delete all your source!)"</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t350" class="pln"><span class="n"><a href="#t350">350</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t351" class="mis show_mis"><span class="n"><a href="#t351">351</a></span><span class="t">        <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">bReplace</span> <span class="key">and</span> <span class="nam">self</span><span class="op">.</span><span class="nam">sOutputName</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t352" class="mis show_mis"><span class="n"><a href="#t352">352</a></span><span class="t">            <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="str">"Can't use -o with -r (they are opposites)"</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t353" class="pln"><span class="n"><a href="#t353">353</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t354" class="pln"><span class="n"><a href="#t354">354</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t355" class="run"><span class="n"><a href="#t355">355</a></span><span class="t"><span class="key">class</span> <span class="nam">Cog</span><span class="op">(</span><span class="nam">Redirectable</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t356" class="pln"><span class="n"><a href="#t356">356</a></span><span class="t">    <span class="str">""" The Cog engine.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t357" class="pln"><span class="n"><a href="#t357">357</a></span><span class="t"><span class="str">    """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t358" class="run"><span class="n"><a href="#t358">358</a></span><span class="t">    <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t359" class="run"><span class="n"><a href="#t359">359</a></span><span class="t">        <span class="nam">Redirectable</span><span class="op">.</span><span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t360" class="run"><span class="n"><a href="#t360">360</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">options</span> <span class="op">=</span> <span class="nam">CogOptions</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t361" class="run"><span class="n"><a href="#t361">361</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">_fixEndOutputPatterns</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t362" class="run"><span class="n"><a href="#t362">362</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodulename</span> <span class="op">=</span> <span class="str">"cog"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t363" class="run"><span class="n"><a href="#t363">363</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">installCogModule</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t364" class="pln"><span class="n"><a href="#t364">364</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t365" class="run"><span class="n"><a href="#t365">365</a></span><span class="t">    <span class="key">def</span> <span class="nam">_fixEndOutputPatterns</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t366" class="run"><span class="n"><a href="#t366">366</a></span><span class="t">        <span class="nam">end_output</span> <span class="op">=</span> <span class="nam">re</span><span class="op">.</span><span class="nam">escape</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t367" class="run"><span class="n"><a href="#t367">367</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">reEndOutput</span> <span class="op">=</span> <span class="nam">re</span><span class="op">.</span><span class="nam">compile</span><span class="op">(</span><span class="nam">end_output</span> <span class="op">+</span> <span class="str">r'(?P&lt;hashsect> *\(checksum: (?P&lt;hash>[a-f0-9]+)\))'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t368" class="run"><span class="n"><a href="#t368">368</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">sEndFormat</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span> <span class="op">+</span> <span class="str">' (checksum: %s)'</span>&nbsp;</span><span class="r"></span></p>
    <p id="t369" class="pln"><span class="n"><a href="#t369">369</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t370" class="run"><span class="n"><a href="#t370">370</a></span><span class="t">    <span class="key">def</span> <span class="nam">showWarning</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">msg</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t371" class="mis show_mis"><span class="n"><a href="#t371">371</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">"Warning: "</span><span class="op">+</span><span class="nam">msg</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t372" class="pln"><span class="n"><a href="#t372">372</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t373" class="run"><span class="n"><a href="#t373">373</a></span><span class="t">    <span class="key">def</span> <span class="nam">isBeginSpecLine</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t374" class="run"><span class="n"><a href="#t374">374</a></span><span class="t">        <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sBeginSpec</span> <span class="key">in</span> <span class="nam">s</span>&nbsp;</span><span class="r"></span></p>
    <p id="t375" class="pln"><span class="n"><a href="#t375">375</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t376" class="run"><span class="n"><a href="#t376">376</a></span><span class="t">    <span class="key">def</span> <span class="nam">isEndSpecLine</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t377" class="run"><span class="n"><a href="#t377">377</a></span><span class="t">        <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndSpec</span> <span class="key">in</span> <span class="nam">s</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndOutputLine</span><span class="op">(</span><span class="nam">s</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t378" class="pln"><span class="n"><a href="#t378">378</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t379" class="run"><span class="n"><a href="#t379">379</a></span><span class="t">    <span class="key">def</span> <span class="nam">isEndOutputLine</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">s</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t380" class="run"><span class="n"><a href="#t380">380</a></span><span class="t">        <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span> <span class="key">in</span> <span class="nam">s</span>&nbsp;</span><span class="r"></span></p>
    <p id="t381" class="pln"><span class="n"><a href="#t381">381</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t382" class="run"><span class="n"><a href="#t382">382</a></span><span class="t">    <span class="key">def</span> <span class="nam">installCogModule</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t383" class="pln"><span class="n"><a href="#t383">383</a></span><span class="t">        <span class="str">""" Magic mumbo-jumbo so that imported Python modules</span>&nbsp;</span><span class="r"></span></p>
    <p id="t384" class="pln"><span class="n"><a href="#t384">384</a></span><span class="t"><span class="str">            can say "import cog" and get our state.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t385" class="pln"><span class="n"><a href="#t385">385</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t386" class="run"><span class="n"><a href="#t386">386</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span> <span class="op">=</span> <span class="nam">imp</span><span class="op">.</span><span class="nam">new_module</span><span class="op">(</span><span class="str">'cog'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t387" class="run"><span class="n"><a href="#t387">387</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">path</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t388" class="pln"><span class="n"><a href="#t388">388</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t389" class="run"><span class="n"><a href="#t389">389</a></span><span class="t">    <span class="key">def</span> <span class="nam">openOutputFile</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t390" class="pln"><span class="n"><a href="#t390">390</a></span><span class="t">        <span class="str">""" Open an output file, taking all the details into account.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t391" class="pln"><span class="n"><a href="#t391">391</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t392" class="mis show_mis"><span class="n"><a href="#t392">392</a></span><span class="t">        <span class="nam">opts</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span>&nbsp;</span><span class="r"></span></p>
    <p id="t393" class="mis show_mis"><span class="n"><a href="#t393">393</a></span><span class="t">        <span class="nam">mode</span> <span class="op">=</span> <span class="str">"w"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t394" class="mis show_mis"><span class="n"><a href="#t394">394</a></span><span class="t">        <span class="key">if</span> <span class="nam">PY3</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t395" class="mis show_mis"><span class="n"><a href="#t395">395</a></span><span class="t">            <span class="nam">opts</span><span class="op">[</span><span class="str">'encoding'</span><span class="op">]</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEncoding</span>&nbsp;</span><span class="r"></span></p>
    <p id="t396" class="mis show_mis"><span class="n"><a href="#t396">396</a></span><span class="t">        <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bNewlines</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t397" class="mis show_mis"><span class="n"><a href="#t397">397</a></span><span class="t">            <span class="key">if</span> <span class="nam">PY3</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t398" class="mis show_mis"><span class="n"><a href="#t398">398</a></span><span class="t">                <span class="nam">opts</span><span class="op">[</span><span class="str">'newline'</span><span class="op">]</span> <span class="op">=</span> <span class="str">"\n"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t399" class="pln"><span class="n"><a href="#t399">399</a></span><span class="t">            <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t400" class="mis show_mis"><span class="n"><a href="#t400">400</a></span><span class="t">                <span class="nam">mode</span> <span class="op">=</span> <span class="str">"wb"</span>&nbsp;</span><span class="r"></span></p>
    <p id="t401" class="mis show_mis"><span class="n"><a href="#t401">401</a></span><span class="t">        <span class="nam">fdir</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">fname</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t402" class="mis show_mis"><span class="n"><a href="#t402">402</a></span><span class="t">        <span class="key">if</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">fdir</span><span class="op">)</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">fdir</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t403" class="mis show_mis"><span class="n"><a href="#t403">403</a></span><span class="t">            <span class="nam">os</span><span class="op">.</span><span class="nam">makedirs</span><span class="op">(</span><span class="nam">fdir</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t404" class="mis show_mis"><span class="n"><a href="#t404">404</a></span><span class="t">        <span class="key">return</span> <span class="nam">open</span><span class="op">(</span><span class="nam">fname</span><span class="op">,</span> <span class="nam">mode</span><span class="op">,</span> <span class="op">**</span><span class="nam">opts</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t405" class="pln"><span class="n"><a href="#t405">405</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t406" class="run"><span class="n"><a href="#t406">406</a></span><span class="t">    <span class="key">def</span> <span class="nam">openInputFile</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">fname</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t407" class="pln"><span class="n"><a href="#t407">407</a></span><span class="t">        <span class="str">""" Open an input file. """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t408" class="mis show_mis"><span class="n"><a href="#t408">408</a></span><span class="t">        <span class="key">if</span> <span class="nam">fname</span> <span class="op">==</span> <span class="str">"-"</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t409" class="mis show_mis"><span class="n"><a href="#t409">409</a></span><span class="t">            <span class="key">return</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">stdin</span>&nbsp;</span><span class="r"></span></p>
    <p id="t410" class="pln"><span class="n"><a href="#t410">410</a></span><span class="t">        <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t411" class="mis show_mis"><span class="n"><a href="#t411">411</a></span><span class="t">            <span class="nam">opts</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span>&nbsp;</span><span class="r"></span></p>
    <p id="t412" class="mis show_mis"><span class="n"><a href="#t412">412</a></span><span class="t">            <span class="key">if</span> <span class="nam">PY3</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t413" class="mis show_mis"><span class="n"><a href="#t413">413</a></span><span class="t">                <span class="nam">opts</span><span class="op">[</span><span class="str">'encoding'</span><span class="op">]</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEncoding</span>&nbsp;</span><span class="r"></span></p>
    <p id="t414" class="mis show_mis"><span class="n"><a href="#t414">414</a></span><span class="t">            <span class="key">return</span> <span class="nam">open</span><span class="op">(</span><span class="nam">fname</span><span class="op">,</span> <span class="str">"r"</span><span class="op">,</span> <span class="op">**</span><span class="nam">opts</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t415" class="pln"><span class="n"><a href="#t415">415</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t416" class="run"><span class="n"><a href="#t416">416</a></span><span class="t">    <span class="key">def</span> <span class="nam">processFile</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">fIn</span><span class="op">,</span> <span class="nam">fOut</span><span class="op">,</span> <span class="nam">fname</span><span class="op">=</span><span class="key">None</span><span class="op">,</span> <span class="nam">globals</span><span class="op">=</span><span class="key">None</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t417" class="pln"><span class="n"><a href="#t417">417</a></span><span class="t">        <span class="str">""" Process an input file object to an output file object.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t418" class="pln"><span class="n"><a href="#t418">418</a></span><span class="t"><span class="str">            fIn and fOut can be file objects, or file names.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t419" class="pln"><span class="n"><a href="#t419">419</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t420" class="pln"><span class="n"><a href="#t420">420</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t421" class="run"><span class="n"><a href="#t421">421</a></span><span class="t">        <span class="nam">sFileIn</span> <span class="op">=</span> <span class="nam">fname</span> <span class="key">or</span> <span class="str">''</span>&nbsp;</span><span class="r"></span></p>
    <p id="t422" class="run"><span class="n"><a href="#t422">422</a></span><span class="t">        <span class="nam">sFileOut</span> <span class="op">=</span> <span class="nam">fname</span> <span class="key">or</span> <span class="str">''</span>&nbsp;</span><span class="r"></span></p>
    <p id="t423" class="run"><span class="n"><a href="#t423">423</a></span><span class="t">        <span class="nam">fInToClose</span> <span class="op">=</span> <span class="nam">fOutToClose</span> <span class="op">=</span> <span class="key">None</span>&nbsp;</span><span class="r"></span></p>
    <p id="t424" class="pln"><span class="n"><a href="#t424">424</a></span><span class="t">        <span class="com"># Convert filenames to files.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t425" class="par run show_par"><span class="n"><a href="#t425">425</a></span><span class="t">        <span class="key">if</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">fIn</span><span class="op">,</span> <span class="nam">string_types</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">425&#x202F;&#x219B;&#x202F;427</span><span class="annotate long">line 425 didn't jump to line 427, because the condition on line 425 was never true</span></span></p>
    <p id="t426" class="pln"><span class="n"><a href="#t426">426</a></span><span class="t">            <span class="com"># Open the input file.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t427" class="mis show_mis"><span class="n"><a href="#t427">427</a></span><span class="t">            <span class="nam">sFileIn</span> <span class="op">=</span> <span class="nam">fIn</span>&nbsp;</span><span class="r"></span></p>
    <p id="t428" class="mis show_mis"><span class="n"><a href="#t428">428</a></span><span class="t">            <span class="nam">fIn</span> <span class="op">=</span> <span class="nam">fInToClose</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">openInputFile</span><span class="op">(</span><span class="nam">fIn</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t429" class="par run show_par"><span class="n"><a href="#t429">429</a></span><span class="t">        <span class="key">if</span> <span class="nam">isinstance</span><span class="op">(</span><span class="nam">fOut</span><span class="op">,</span> <span class="nam">string_types</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">429&#x202F;&#x219B;&#x202F;431</span><span class="annotate long">line 429 didn't jump to line 431, because the condition on line 429 was never true</span></span></p>
    <p id="t430" class="pln"><span class="n"><a href="#t430">430</a></span><span class="t">            <span class="com"># Open the output file.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t431" class="mis show_mis"><span class="n"><a href="#t431">431</a></span><span class="t">            <span class="nam">sFileOut</span> <span class="op">=</span> <span class="nam">fOut</span>&nbsp;</span><span class="r"></span></p>
    <p id="t432" class="mis show_mis"><span class="n"><a href="#t432">432</a></span><span class="t">            <span class="nam">fOut</span> <span class="op">=</span> <span class="nam">fOutToClose</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">openOutputFile</span><span class="op">(</span><span class="nam">fOut</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t433" class="pln"><span class="n"><a href="#t433">433</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t434" class="run"><span class="n"><a href="#t434">434</a></span><span class="t">        <span class="key">try</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t435" class="run"><span class="n"><a href="#t435">435</a></span><span class="t">            <span class="nam">fIn</span> <span class="op">=</span> <span class="nam">NumberedFileReader</span><span class="op">(</span><span class="nam">fIn</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t436" class="pln"><span class="n"><a href="#t436">436</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t437" class="run"><span class="n"><a href="#t437">437</a></span><span class="t">            <span class="nam">bSawCog</span> <span class="op">=</span> <span class="key">False</span>&nbsp;</span><span class="r"></span></p>
    <p id="t438" class="pln"><span class="n"><a href="#t438">438</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t439" class="run"><span class="n"><a href="#t439">439</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">inFile</span> <span class="op">=</span> <span class="nam">sFileIn</span>&nbsp;</span><span class="r"></span></p>
    <p id="t440" class="run"><span class="n"><a href="#t440">440</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">outFile</span> <span class="op">=</span> <span class="nam">sFileOut</span>&nbsp;</span><span class="r"></span></p>
    <p id="t441" class="run"><span class="n"><a href="#t441">441</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodulename</span> <span class="op">=</span> <span class="str">'cog_'</span> <span class="op">+</span> <span class="nam">hashlib</span><span class="op">.</span><span class="nam">md5</span><span class="op">(</span><span class="nam">sFileOut</span><span class="op">.</span><span class="nam">encode</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">.</span><span class="nam">hexdigest</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t442" class="run"><span class="n"><a href="#t442">442</a></span><span class="t">            <span class="nam">sys</span><span class="op">.</span><span class="nam">modules</span><span class="op">[</span><span class="nam">self</span><span class="op">.</span><span class="nam">cogmodulename</span><span class="op">]</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span>&nbsp;</span><span class="r"></span></p>
    <p id="t443" class="pln"><span class="n"><a href="#t443">443</a></span><span class="t">            <span class="com"># if "import cog" explicitly done in code by user, note threading will cause clashes. </span>&nbsp;</span><span class="r"></span></p>
    <p id="t444" class="run"><span class="n"><a href="#t444">444</a></span><span class="t">            <span class="nam">sys</span><span class="op">.</span><span class="nam">modules</span><span class="op">[</span><span class="str">'cog'</span><span class="op">]</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span>&nbsp;</span><span class="r"></span></p>
    <p id="t445" class="pln"><span class="n"><a href="#t445">445</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t446" class="pln"><span class="n"><a href="#t446">446</a></span><span class="t">            <span class="com"># The globals dict we'll use for this file.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t447" class="par run show_par"><span class="n"><a href="#t447">447</a></span><span class="t">            <span class="key">if</span> <span class="nam">globals</span> <span class="key">is</span> <span class="key">None</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">447&#x202F;&#x219B;&#x202F;451</span><span class="annotate long">line 447 didn't jump to line 451, because the condition on line 447 was never false</span></span></p>
    <p id="t448" class="run"><span class="n"><a href="#t448">448</a></span><span class="t">                <span class="nam">globals</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span>&nbsp;</span><span class="r"></span></p>
    <p id="t449" class="pln"><span class="n"><a href="#t449">449</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t450" class="pln"><span class="n"><a href="#t450">450</a></span><span class="t">            <span class="com"># If there are any global defines, put them in the globals.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t451" class="run"><span class="n"><a href="#t451">451</a></span><span class="t">            <span class="nam">globals</span><span class="op">.</span><span class="nam">update</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">defines</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t452" class="pln"><span class="n"><a href="#t452">452</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t453" class="pln"><span class="n"><a href="#t453">453</a></span><span class="t">            <span class="com"># loop over generator chunks</span>&nbsp;</span><span class="r"></span></p>
    <p id="t454" class="run"><span class="n"><a href="#t454">454</a></span><span class="t">            <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t455" class="run"><span class="n"><a href="#t455">455</a></span><span class="t">            <span class="key">while</span> <span class="nam">l</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t456" class="pln"><span class="n"><a href="#t456">456</a></span><span class="t">                <span class="com"># Find the next spec begin</span>&nbsp;</span><span class="r"></span></p>
    <p id="t457" class="run"><span class="n"><a href="#t457">457</a></span><span class="t">                <span class="key">while</span> <span class="nam">l</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isBeginSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t458" class="par run show_par"><span class="n"><a href="#t458">458</a></span><span class="t">                    <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">458&#x202F;&#x219B;&#x202F;459</span><span class="annotate long">line 458 didn't jump to line 459, because the condition on line 458 was never true</span></span></p>
    <p id="t459" class="mis show_mis"><span class="n"><a href="#t459">459</a></span><span class="t">                        <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndSpec</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t460" class="pln"><span class="n"><a href="#t460">460</a></span><span class="t">                            <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t461" class="par run show_par"><span class="n"><a href="#t461">461</a></span><span class="t">                    <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndOutputLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">461&#x202F;&#x219B;&#x202F;462</span><span class="annotate long">line 461 didn't jump to line 462, because the condition on line 461 was never true</span></span></p>
    <p id="t462" class="mis show_mis"><span class="n"><a href="#t462">462</a></span><span class="t">                        <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t463" class="pln"><span class="n"><a href="#t463">463</a></span><span class="t">                            <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t464" class="run"><span class="n"><a href="#t464">464</a></span><span class="t">                    <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t465" class="run"><span class="n"><a href="#t465">465</a></span><span class="t">                    <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t466" class="run"><span class="n"><a href="#t466">466</a></span><span class="t">                <span class="key">if</span> <span class="key">not</span> <span class="nam">l</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t467" class="run"><span class="n"><a href="#t467">467</a></span><span class="t">                    <span class="key">break</span>&nbsp;</span><span class="r"></span></p>
    <p id="t468" class="par run show_par"><span class="n"><a href="#t468">468</a></span><span class="t">                <span class="key">if</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bDeleteCode</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">468&#x202F;&#x219B;&#x202F;472</span><span class="annotate long">line 468 didn't jump to line 472, because the condition on line 468 was never false</span></span></p>
    <p id="t469" class="run"><span class="n"><a href="#t469">469</a></span><span class="t">                    <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t470" class="pln"><span class="n"><a href="#t470">470</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t471" class="pln"><span class="n"><a href="#t471">471</a></span><span class="t">                <span class="com"># l is the begin spec</span>&nbsp;</span><span class="r"></span></p>
    <p id="t472" class="run"><span class="n"><a href="#t472">472</a></span><span class="t">                <span class="nam">gen</span> <span class="op">=</span> <span class="nam">CogGenerator</span><span class="op">(</span><span class="nam">options</span><span class="op">=</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t473" class="run"><span class="n"><a href="#t473">473</a></span><span class="t">                <span class="nam">gen</span><span class="op">.</span><span class="nam">setOutput</span><span class="op">(</span><span class="nam">stdout</span><span class="op">=</span><span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t474" class="run"><span class="n"><a href="#t474">474</a></span><span class="t">                <span class="nam">gen</span><span class="op">.</span><span class="nam">parseMarker</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t475" class="run"><span class="n"><a href="#t475">475</a></span><span class="t">                <span class="nam">firstLineNum</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t476" class="run"><span class="n"><a href="#t476">476</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">firstLineNum</span> <span class="op">=</span> <span class="nam">firstLineNum</span>&nbsp;</span><span class="r"></span></p>
    <p id="t477" class="pln"><span class="n"><a href="#t477">477</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t478" class="pln"><span class="n"><a href="#t478">478</a></span><span class="t">                <span class="com"># If the spec begin is also a spec end, then process the single</span>&nbsp;</span><span class="r"></span></p>
    <p id="t479" class="pln"><span class="n"><a href="#t479">479</a></span><span class="t">                <span class="com"># line of code inside.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t480" class="run"><span class="n"><a href="#t480">480</a></span><span class="t">                <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t481" class="run"><span class="n"><a href="#t481">481</a></span><span class="t">                    <span class="nam">beg</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">find</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t482" class="run"><span class="n"><a href="#t482">482</a></span><span class="t">                    <span class="nam">end</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">find</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndSpec</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t483" class="run"><span class="n"><a href="#t483">483</a></span><span class="t">                    <span class="key">if</span> <span class="nam">beg</span> <span class="op">></span> <span class="nam">end</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t484" class="run"><span class="n"><a href="#t484">484</a></span><span class="t">                        <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Cog code markers inverted"</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t485" class="pln"><span class="n"><a href="#t485">485</a></span><span class="t">                            <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">firstLineNum</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t486" class="pln"><span class="n"><a href="#t486">486</a></span><span class="t">                    <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t487" class="run"><span class="n"><a href="#t487">487</a></span><span class="t">                        <span class="nam">sCode</span> <span class="op">=</span> <span class="nam">l</span><span class="op">[</span><span class="nam">beg</span><span class="op">+</span><span class="nam">len</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">)</span><span class="op">:</span><span class="nam">end</span><span class="op">]</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t488" class="run"><span class="n"><a href="#t488">488</a></span><span class="t">                        <span class="nam">gen</span><span class="op">.</span><span class="nam">parseLine</span><span class="op">(</span><span class="nam">sCode</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t489" class="pln"><span class="n"><a href="#t489">489</a></span><span class="t">                <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t490" class="pln"><span class="n"><a href="#t490">490</a></span><span class="t">                    <span class="com"># Deal with an ordinary code block.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t491" class="run"><span class="n"><a href="#t491">491</a></span><span class="t">                    <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t492" class="pln"><span class="n"><a href="#t492">492</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t493" class="pln"><span class="n"><a href="#t493">493</a></span><span class="t">                    <span class="com"># Get all the lines in the spec</span>&nbsp;</span><span class="r"></span></p>
    <p id="t494" class="run"><span class="n"><a href="#t494">494</a></span><span class="t">                    <span class="key">while</span> <span class="nam">l</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t495" class="par run show_par"><span class="n"><a href="#t495">495</a></span><span class="t">                        <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isBeginSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">495&#x202F;&#x219B;&#x202F;496</span><span class="annotate long">line 495 didn't jump to line 496, because the condition on line 495 was never true</span></span></p>
    <p id="t496" class="mis show_mis"><span class="n"><a href="#t496">496</a></span><span class="t">                            <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t497" class="pln"><span class="n"><a href="#t497">497</a></span><span class="t">                                <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t498" class="par run show_par"><span class="n"><a href="#t498">498</a></span><span class="t">                        <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndOutputLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">498&#x202F;&#x219B;&#x202F;499</span><span class="annotate long">line 498 didn't jump to line 499, because the condition on line 498 was never true</span></span></p>
    <p id="t499" class="mis show_mis"><span class="n"><a href="#t499">499</a></span><span class="t">                            <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t500" class="pln"><span class="n"><a href="#t500">500</a></span><span class="t">                                <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t501" class="par run show_par"><span class="n"><a href="#t501">501</a></span><span class="t">                        <span class="key">if</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bDeleteCode</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">501&#x202F;&#x219B;&#x202F;503</span><span class="annotate long">line 501 didn't jump to line 503, because the condition on line 501 was never false</span></span></p>
    <p id="t502" class="run"><span class="n"><a href="#t502">502</a></span><span class="t">                            <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t503" class="run"><span class="n"><a href="#t503">503</a></span><span class="t">                        <span class="nam">gen</span><span class="op">.</span><span class="nam">parseLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t504" class="run"><span class="n"><a href="#t504">504</a></span><span class="t">                        <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t505" class="par run show_par"><span class="n"><a href="#t505">505</a></span><span class="t">                    <span class="key">if</span> <span class="key">not</span> <span class="nam">l</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">505&#x202F;&#x219B;&#x202F;506</span><span class="annotate long">line 505 didn't jump to line 506, because the condition on line 505 was never true</span></span></p>
    <p id="t506" class="mis show_mis"><span class="n"><a href="#t506">506</a></span><span class="t">                        <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span>&nbsp;</span><span class="r"></span></p>
    <p id="t507" class="pln"><span class="n"><a href="#t507">507</a></span><span class="t">                            <span class="str">"Cog block begun but never ended."</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t508" class="pln"><span class="n"><a href="#t508">508</a></span><span class="t">                            <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">firstLineNum</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t509" class="pln"><span class="n"><a href="#t509">509</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t510" class="par run show_par"><span class="n"><a href="#t510">510</a></span><span class="t">                    <span class="key">if</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bDeleteCode</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">510&#x202F;&#x219B;&#x202F;512</span><span class="annotate long">line 510 didn't jump to line 512, because the condition on line 510 was never false</span></span></p>
    <p id="t511" class="run"><span class="n"><a href="#t511">511</a></span><span class="t">                        <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t512" class="run"><span class="n"><a href="#t512">512</a></span><span class="t">                    <span class="nam">gen</span><span class="op">.</span><span class="nam">parseMarker</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t513" class="pln"><span class="n"><a href="#t513">513</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t514" class="run"><span class="n"><a href="#t514">514</a></span><span class="t">                <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t515" class="pln"><span class="n"><a href="#t515">515</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t516" class="pln"><span class="n"><a href="#t516">516</a></span><span class="t">                <span class="com"># Eat all the lines in the output section.  While reading past</span>&nbsp;</span><span class="r"></span></p>
    <p id="t517" class="pln"><span class="n"><a href="#t517">517</a></span><span class="t">                <span class="com"># them, compute the md5 hash of the old output.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t518" class="run"><span class="n"><a href="#t518">518</a></span><span class="t">                <span class="nam">previous</span> <span class="op">=</span> <span class="str">""</span>&nbsp;</span><span class="r"></span></p>
    <p id="t519" class="run"><span class="n"><a href="#t519">519</a></span><span class="t">                <span class="nam">hasher</span> <span class="op">=</span> <span class="nam">hashlib</span><span class="op">.</span><span class="nam">md5</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t520" class="run"><span class="n"><a href="#t520">520</a></span><span class="t">                <span class="key">while</span> <span class="nam">l</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndOutputLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t521" class="par run show_par"><span class="n"><a href="#t521">521</a></span><span class="t">                    <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isBeginSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">521&#x202F;&#x219B;&#x202F;522</span><span class="annotate long">line 521 didn't jump to line 522, because the condition on line 521 was never true</span></span></p>
    <p id="t522" class="mis show_mis"><span class="n"><a href="#t522">522</a></span><span class="t">                        <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sBeginSpec</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t523" class="pln"><span class="n"><a href="#t523">523</a></span><span class="t">                            <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t524" class="par run show_par"><span class="n"><a href="#t524">524</a></span><span class="t">                    <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">isEndSpecLine</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">524&#x202F;&#x219B;&#x202F;525</span><span class="annotate long">line 524 didn't jump to line 525, because the condition on line 524 was never true</span></span></p>
    <p id="t525" class="mis show_mis"><span class="n"><a href="#t525">525</a></span><span class="t">                        <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Unexpected '%s'"</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndSpec</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t526" class="pln"><span class="n"><a href="#t526">526</a></span><span class="t">                            <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t527" class="run"><span class="n"><a href="#t527">527</a></span><span class="t">                    <span class="nam">previous</span> <span class="op">+=</span> <span class="nam">l</span>&nbsp;</span><span class="r"></span></p>
    <p id="t528" class="run"><span class="n"><a href="#t528">528</a></span><span class="t">                    <span class="nam">hasher</span><span class="op">.</span><span class="nam">update</span><span class="op">(</span><span class="nam">to_bytes</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t529" class="run"><span class="n"><a href="#t529">529</a></span><span class="t">                    <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t530" class="run"><span class="n"><a href="#t530">530</a></span><span class="t">                <span class="nam">curHash</span> <span class="op">=</span> <span class="nam">hasher</span><span class="op">.</span><span class="nam">hexdigest</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t531" class="pln"><span class="n"><a href="#t531">531</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t532" class="par run show_par"><span class="n"><a href="#t532">532</a></span><span class="t">                <span class="key">if</span> <span class="key">not</span> <span class="nam">l</span> <span class="key">and</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bEofCanBeEnd</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">532&#x202F;&#x219B;&#x202F;534</span><span class="annotate long">line 532 didn't jump to line 534, because the condition on line 532 was never true</span></span></p>
    <p id="t533" class="pln"><span class="n"><a href="#t533">533</a></span><span class="t">                    <span class="com"># We reached end of file before we found the end output line.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t534" class="mis show_mis"><span class="n"><a href="#t534">534</a></span><span class="t">                    <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Missing '%s' before end of file."</span> <span class="op">%</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t535" class="pln"><span class="n"><a href="#t535">535</a></span><span class="t">                        <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t536" class="pln"><span class="n"><a href="#t536">536</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t537" class="pln"><span class="n"><a href="#t537">537</a></span><span class="t">                <span class="com"># Make the previous output available to the current code</span>&nbsp;</span><span class="r"></span></p>
    <p id="t538" class="run"><span class="n"><a href="#t538">538</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">previous</span> <span class="op">=</span> <span class="nam">previous</span>&nbsp;</span><span class="r"></span></p>
    <p id="t539" class="pln"><span class="n"><a href="#t539">539</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t540" class="pln"><span class="n"><a href="#t540">540</a></span><span class="t">                <span class="com"># Write the output of the spec to be the new output if we're</span>&nbsp;</span><span class="r"></span></p>
    <p id="t541" class="pln"><span class="n"><a href="#t541">541</a></span><span class="t">                <span class="com"># supposed to generate code.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t542" class="run"><span class="n"><a href="#t542">542</a></span><span class="t">                <span class="nam">hasher</span> <span class="op">=</span> <span class="nam">hashlib</span><span class="op">.</span><span class="nam">md5</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t543" class="par run show_par"><span class="n"><a href="#t543">543</a></span><span class="t">                <span class="key">if</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bNoGenerate</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">543&#x202F;&#x219B;&#x202F;549</span><span class="annotate long">line 543 didn't jump to line 549, because the condition on line 543 was never false</span></span></p>
    <p id="t544" class="run"><span class="n"><a href="#t544">544</a></span><span class="t">                    <span class="nam">sFile</span> <span class="op">=</span> <span class="str">"&lt;cog %s:%d>"</span> <span class="op">%</span> <span class="op">(</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">firstLineNum</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t545" class="run"><span class="n"><a href="#t545">545</a></span><span class="t">                    <span class="nam">sGen</span> <span class="op">=</span> <span class="nam">gen</span><span class="op">.</span><span class="nam">evaluate</span><span class="op">(</span><span class="nam">cog</span><span class="op">=</span><span class="nam">self</span><span class="op">,</span> <span class="nam">globals</span><span class="op">=</span><span class="nam">globals</span><span class="op">,</span> <span class="nam">fname</span><span class="op">=</span><span class="nam">sFile</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t546" class="run"><span class="n"><a href="#t546">546</a></span><span class="t">                    <span class="nam">sGen</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">suffixLines</span><span class="op">(</span><span class="nam">sGen</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t547" class="run"><span class="n"><a href="#t547">547</a></span><span class="t">                    <span class="nam">hasher</span><span class="op">.</span><span class="nam">update</span><span class="op">(</span><span class="nam">to_bytes</span><span class="op">(</span><span class="nam">sGen</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t548" class="run"><span class="n"><a href="#t548">548</a></span><span class="t">                    <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">sGen</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t549" class="run"><span class="n"><a href="#t549">549</a></span><span class="t">                <span class="nam">newHash</span> <span class="op">=</span> <span class="nam">hasher</span><span class="op">.</span><span class="nam">hexdigest</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t550" class="pln"><span class="n"><a href="#t550">550</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t551" class="run"><span class="n"><a href="#t551">551</a></span><span class="t">                <span class="nam">bSawCog</span> <span class="op">=</span> <span class="key">True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t552" class="pln"><span class="n"><a href="#t552">552</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t553" class="pln"><span class="n"><a href="#t553">553</a></span><span class="t">                <span class="com"># Write the ending output line</span>&nbsp;</span><span class="r"></span></p>
    <p id="t554" class="run"><span class="n"><a href="#t554">554</a></span><span class="t">                <span class="nam">hashMatch</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">reEndOutput</span><span class="op">.</span><span class="nam">search</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t555" class="par run show_par"><span class="n"><a href="#t555">555</a></span><span class="t">                <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bHashOutput</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">555&#x202F;&#x219B;&#x202F;556</span><span class="annotate long">line 555 didn't jump to line 556, because the condition on line 555 was never true</span></span></p>
    <p id="t556" class="mis show_mis"><span class="n"><a href="#t556">556</a></span><span class="t">                    <span class="key">if</span> <span class="nam">hashMatch</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t557" class="mis show_mis"><span class="n"><a href="#t557">557</a></span><span class="t">                        <span class="nam">oldHash</span> <span class="op">=</span> <span class="nam">hashMatch</span><span class="op">.</span><span class="nam">groupdict</span><span class="op">(</span><span class="op">)</span><span class="op">[</span><span class="str">'hash'</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t558" class="mis show_mis"><span class="n"><a href="#t558">558</a></span><span class="t">                        <span class="key">if</span> <span class="nam">oldHash</span> <span class="op">!=</span> <span class="nam">curHash</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t559" class="mis show_mis"><span class="n"><a href="#t559">559</a></span><span class="t">                            <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Output has been edited! Delete old checksum to unprotect."</span><span class="op">,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t560" class="pln"><span class="n"><a href="#t560">560</a></span><span class="t">                                <span class="nam">file</span><span class="op">=</span><span class="nam">sFileIn</span><span class="op">,</span> <span class="nam">line</span><span class="op">=</span><span class="nam">fIn</span><span class="op">.</span><span class="nam">linenumber</span><span class="op">(</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t561" class="pln"><span class="n"><a href="#t561">561</a></span><span class="t">                        <span class="com"># Create a new end line with the correct hash.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t562" class="mis show_mis"><span class="n"><a href="#t562">562</a></span><span class="t">                        <span class="nam">endpieces</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="nam">hashMatch</span><span class="op">.</span><span class="nam">group</span><span class="op">(</span><span class="num">0</span><span class="op">)</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t563" class="pln"><span class="n"><a href="#t563">563</a></span><span class="t">                    <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t564" class="pln"><span class="n"><a href="#t564">564</a></span><span class="t">                        <span class="com"># There was no old hash, but we want a new hash.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t565" class="mis show_mis"><span class="n"><a href="#t565">565</a></span><span class="t">                        <span class="nam">endpieces</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sEndOutput</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t566" class="mis show_mis"><span class="n"><a href="#t566">566</a></span><span class="t">                    <span class="nam">l</span> <span class="op">=</span> <span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">sEndFormat</span> <span class="op">%</span> <span class="nam">newHash</span><span class="op">)</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">endpieces</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t567" class="pln"><span class="n"><a href="#t567">567</a></span><span class="t">                <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t568" class="pln"><span class="n"><a href="#t568">568</a></span><span class="t">                    <span class="com"># We don't want hashes output, so if there was one, get rid of</span>&nbsp;</span><span class="r"></span></p>
    <p id="t569" class="pln"><span class="n"><a href="#t569">569</a></span><span class="t">                    <span class="com"># it.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t570" class="par run show_par"><span class="n"><a href="#t570">570</a></span><span class="t">                    <span class="key">if</span> <span class="nam">hashMatch</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">570&#x202F;&#x219B;&#x202F;571</span><span class="annotate long">line 570 didn't jump to line 571, because the condition on line 570 was never true</span></span></p>
    <p id="t571" class="mis show_mis"><span class="n"><a href="#t571">571</a></span><span class="t">                        <span class="nam">l</span> <span class="op">=</span> <span class="nam">l</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="nam">hashMatch</span><span class="op">.</span><span class="nam">groupdict</span><span class="op">(</span><span class="op">)</span><span class="op">[</span><span class="str">'hashsect'</span><span class="op">]</span><span class="op">,</span> <span class="str">''</span><span class="op">,</span> <span class="num">1</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t572" class="pln"><span class="n"><a href="#t572">572</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t573" class="par run show_par"><span class="n"><a href="#t573">573</a></span><span class="t">                <span class="key">if</span> <span class="key">not</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bDeleteCode</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">573&#x202F;&#x219B;&#x202F;575</span><span class="annotate long">line 573 didn't jump to line 575, because the condition on line 573 was never false</span></span></p>
    <p id="t574" class="run"><span class="n"><a href="#t574">574</a></span><span class="t">                    <span class="nam">fOut</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">l</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t575" class="run"><span class="n"><a href="#t575">575</a></span><span class="t">                <span class="nam">l</span> <span class="op">=</span> <span class="nam">fIn</span><span class="op">.</span><span class="nam">readline</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t576" class="pln"><span class="n"><a href="#t576">576</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t577" class="par run show_par"><span class="n"><a href="#t577">577</a></span><span class="t">            <span class="key">if</span> <span class="key">not</span> <span class="nam">bSawCog</span> <span class="key">and</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bWarnEmpty</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">577&#x202F;&#x219B;&#x202F;578</span><span class="annotate long">line 577 didn't jump to line 578, because the condition on line 577 was never true</span></span></p>
    <p id="t578" class="mis show_mis"><span class="n"><a href="#t578">578</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">showWarning</span><span class="op">(</span><span class="str">"no cog code found in %s"</span> <span class="op">%</span> <span class="nam">sFileIn</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t579" class="pln"><span class="n"><a href="#t579">579</a></span><span class="t">        <span class="key">finally</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t580" class="par run show_par"><span class="n"><a href="#t580">580</a></span><span class="t">            <span class="key">if</span> <span class="nam">fInToClose</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">580&#x202F;&#x219B;&#x202F;581</span><span class="annotate long">line 580 didn't jump to line 581, because the condition on line 580 was never true</span></span></p>
    <p id="t581" class="mis show_mis"><span class="n"><a href="#t581">581</a></span><span class="t">                <span class="nam">fInToClose</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t582" class="par run show_par"><span class="n"><a href="#t582">582</a></span><span class="t">            <span class="key">if</span> <span class="nam">fOutToClose</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">582&#x202F;&#x219B;&#x202F;583</span><span class="annotate long">line 582 didn't jump to line 583, because the condition on line 582 was never true</span></span></p>
    <p id="t583" class="mis show_mis"><span class="n"><a href="#t583">583</a></span><span class="t">                <span class="nam">fOutToClose</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t584" class="pln"><span class="n"><a href="#t584">584</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t585" class="pln"><span class="n"><a href="#t585">585</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t586" class="pln"><span class="n"><a href="#t586">586</a></span><span class="t">    <span class="com"># A regex for non-empty lines, used by suffixLines.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t587" class="run"><span class="n"><a href="#t587">587</a></span><span class="t">    <span class="nam">reNonEmptyLines</span> <span class="op">=</span> <span class="nam">re</span><span class="op">.</span><span class="nam">compile</span><span class="op">(</span><span class="str">r"^\s*\S+.*$"</span><span class="op">,</span> <span class="nam">re</span><span class="op">.</span><span class="nam">MULTILINE</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t588" class="pln"><span class="n"><a href="#t588">588</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t589" class="run"><span class="n"><a href="#t589">589</a></span><span class="t">    <span class="key">def</span> <span class="nam">suffixLines</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">text</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t590" class="pln"><span class="n"><a href="#t590">590</a></span><span class="t">        <span class="str">""" Add suffixes to the lines in text, if our options desire it.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t591" class="pln"><span class="n"><a href="#t591">591</a></span><span class="t"><span class="str">            text is many lines, as a single string.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t592" class="pln"><span class="n"><a href="#t592">592</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t593" class="par run show_par"><span class="n"><a href="#t593">593</a></span><span class="t">        <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sSuffix</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">593&#x202F;&#x219B;&#x202F;595</span><span class="annotate long">line 593 didn't jump to line 595, because the condition on line 593 was never true</span></span></p>
    <p id="t594" class="pln"><span class="n"><a href="#t594">594</a></span><span class="t">            <span class="com"># Find all non-blank lines, and add the suffix to the end.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t595" class="mis show_mis"><span class="n"><a href="#t595">595</a></span><span class="t">            <span class="nam">repl</span> <span class="op">=</span> <span class="str">r"\g&lt;0>"</span> <span class="op">+</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sSuffix</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">'\\'</span><span class="op">,</span> <span class="str">'\\\\'</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t596" class="mis show_mis"><span class="n"><a href="#t596">596</a></span><span class="t">            <span class="nam">text</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">reNonEmptyLines</span><span class="op">.</span><span class="nam">sub</span><span class="op">(</span><span class="nam">repl</span><span class="op">,</span> <span class="nam">text</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t597" class="run"><span class="n"><a href="#t597">597</a></span><span class="t">        <span class="key">return</span> <span class="nam">text</span>&nbsp;</span><span class="r"></span></p>
    <p id="t598" class="pln"><span class="n"><a href="#t598">598</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t599" class="run"><span class="n"><a href="#t599">599</a></span><span class="t">    <span class="key">def</span> <span class="nam">processString</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sInput</span><span class="op">,</span> <span class="nam">fname</span><span class="op">=</span><span class="key">None</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t600" class="pln"><span class="n"><a href="#t600">600</a></span><span class="t">        <span class="str">""" Process sInput as the text to cog.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t601" class="pln"><span class="n"><a href="#t601">601</a></span><span class="t"><span class="str">            Return the cogged output as a string.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t602" class="pln"><span class="n"><a href="#t602">602</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t603" class="run"><span class="n"><a href="#t603">603</a></span><span class="t">        <span class="nam">fOld</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="nam">sInput</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t604" class="run"><span class="n"><a href="#t604">604</a></span><span class="t">        <span class="nam">fNew</span> <span class="op">=</span> <span class="nam">StringIO</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t605" class="run"><span class="n"><a href="#t605">605</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">processFile</span><span class="op">(</span><span class="nam">fOld</span><span class="op">,</span> <span class="nam">fNew</span><span class="op">,</span> <span class="nam">fname</span><span class="op">=</span><span class="nam">fname</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t606" class="run"><span class="n"><a href="#t606">606</a></span><span class="t">        <span class="key">return</span> <span class="nam">fNew</span><span class="op">.</span><span class="nam">getvalue</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t607" class="pln"><span class="n"><a href="#t607">607</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t608" class="run"><span class="n"><a href="#t608">608</a></span><span class="t">    <span class="key">def</span> <span class="nam">replaceFile</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sOldPath</span><span class="op">,</span> <span class="nam">sNewText</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t609" class="pln"><span class="n"><a href="#t609">609</a></span><span class="t">        <span class="str">""" Replace file sOldPath with the contents sNewText</span>&nbsp;</span><span class="r"></span></p>
    <p id="t610" class="pln"><span class="n"><a href="#t610">610</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t611" class="mis show_mis"><span class="n"><a href="#t611">611</a></span><span class="t">        <span class="key">if</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">access</span><span class="op">(</span><span class="nam">sOldPath</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">W_OK</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t612" class="pln"><span class="n"><a href="#t612">612</a></span><span class="t">            <span class="com"># Need to ensure we can write.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t613" class="mis show_mis"><span class="n"><a href="#t613">613</a></span><span class="t">            <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sMakeWritableCmd</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t614" class="pln"><span class="n"><a href="#t614">614</a></span><span class="t">                <span class="com"># Use an external command to make the file writable.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t615" class="mis show_mis"><span class="n"><a href="#t615">615</a></span><span class="t">                <span class="nam">cmd</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sMakeWritableCmd</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">'%s'</span><span class="op">,</span> <span class="nam">sOldPath</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t616" class="mis show_mis"><span class="n"><a href="#t616">616</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">popen</span><span class="op">(</span><span class="nam">cmd</span><span class="op">)</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t617" class="mis show_mis"><span class="n"><a href="#t617">617</a></span><span class="t">                <span class="key">if</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">access</span><span class="op">(</span><span class="nam">sOldPath</span><span class="op">,</span> <span class="nam">os</span><span class="op">.</span><span class="nam">W_OK</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t618" class="mis show_mis"><span class="n"><a href="#t618">618</a></span><span class="t">                    <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Couldn't make %s writable"</span> <span class="op">%</span> <span class="nam">sOldPath</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t619" class="pln"><span class="n"><a href="#t619">619</a></span><span class="t">            <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t620" class="pln"><span class="n"><a href="#t620">620</a></span><span class="t">                <span class="com"># Can't write!</span>&nbsp;</span><span class="r"></span></p>
    <p id="t621" class="mis show_mis"><span class="n"><a href="#t621">621</a></span><span class="t">                <span class="key">raise</span> <span class="nam">CogError</span><span class="op">(</span><span class="str">"Can't overwrite %s"</span> <span class="op">%</span> <span class="nam">sOldPath</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t622" class="mis show_mis"><span class="n"><a href="#t622">622</a></span><span class="t">        <span class="nam">f</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">openOutputFile</span><span class="op">(</span><span class="nam">sOldPath</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t623" class="mis show_mis"><span class="n"><a href="#t623">623</a></span><span class="t">        <span class="nam">f</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">sNewText</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t624" class="mis show_mis"><span class="n"><a href="#t624">624</a></span><span class="t">        <span class="nam">f</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t625" class="pln"><span class="n"><a href="#t625">625</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t626" class="run"><span class="n"><a href="#t626">626</a></span><span class="t">    <span class="key">def</span> <span class="nam">saveIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t627" class="mis show_mis"><span class="n"><a href="#t627">627</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">savedInclude</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">includePath</span><span class="op">[</span><span class="op">:</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t628" class="mis show_mis"><span class="n"><a href="#t628">628</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">savedSysPath</span> <span class="op">=</span> <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">[</span><span class="op">:</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t629" class="pln"><span class="n"><a href="#t629">629</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t630" class="run"><span class="n"><a href="#t630">630</a></span><span class="t">    <span class="key">def</span> <span class="nam">restoreIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t631" class="mis show_mis"><span class="n"><a href="#t631">631</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">includePath</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">savedInclude</span>&nbsp;</span><span class="r"></span></p>
    <p id="t632" class="mis show_mis"><span class="n"><a href="#t632">632</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">path</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">includePath</span>&nbsp;</span><span class="r"></span></p>
    <p id="t633" class="mis show_mis"><span class="n"><a href="#t633">633</a></span><span class="t">        <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">savedSysPath</span>&nbsp;</span><span class="r"></span></p>
    <p id="t634" class="pln"><span class="n"><a href="#t634">634</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t635" class="run"><span class="n"><a href="#t635">635</a></span><span class="t">    <span class="key">def</span> <span class="nam">addToIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">includePath</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t636" class="mis show_mis"><span class="n"><a href="#t636">636</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">cogmodule</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">extend</span><span class="op">(</span><span class="nam">includePath</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t637" class="mis show_mis"><span class="n"><a href="#t637">637</a></span><span class="t">        <span class="nam">sys</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">extend</span><span class="op">(</span><span class="nam">includePath</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t638" class="pln"><span class="n"><a href="#t638">638</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t639" class="run"><span class="n"><a href="#t639">639</a></span><span class="t">    <span class="key">def</span> <span class="nam">processOneFile</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sFile</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t640" class="pln"><span class="n"><a href="#t640">640</a></span><span class="t">        <span class="str">""" Process one filename through cog.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t641" class="pln"><span class="n"><a href="#t641">641</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t642" class="pln"><span class="n"><a href="#t642">642</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t643" class="mis show_mis"><span class="n"><a href="#t643">643</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">saveIncludePath</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t644" class="mis show_mis"><span class="n"><a href="#t644">644</a></span><span class="t">        <span class="nam">bNeedNewline</span> <span class="op">=</span> <span class="key">False</span>&nbsp;</span><span class="r"></span></p>
    <p id="t645" class="pln"><span class="n"><a href="#t645">645</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t646" class="mis show_mis"><span class="n"><a href="#t646">646</a></span><span class="t">        <span class="key">try</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t647" class="mis show_mis"><span class="n"><a href="#t647">647</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">addToIncludePath</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">includePath</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t648" class="pln"><span class="n"><a href="#t648">648</a></span><span class="t">            <span class="com"># Since we know where the input file came from,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t649" class="pln"><span class="n"><a href="#t649">649</a></span><span class="t">            <span class="com"># push its directory onto the include path.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t650" class="mis show_mis"><span class="n"><a href="#t650">650</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">addToIncludePath</span><span class="op">(</span><span class="op">[</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">sFile</span><span class="op">)</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t651" class="pln"><span class="n"><a href="#t651">651</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t652" class="pln"><span class="n"><a href="#t652">652</a></span><span class="t">            <span class="com"># How we process the file depends on where the output is going.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t653" class="mis show_mis"><span class="n"><a href="#t653">653</a></span><span class="t">            <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sOutputName</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t654" class="mis show_mis"><span class="n"><a href="#t654">654</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">processFile</span><span class="op">(</span><span class="nam">sFile</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sOutputName</span><span class="op">,</span> <span class="nam">sFile</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t655" class="mis show_mis"><span class="n"><a href="#t655">655</a></span><span class="t">            <span class="key">elif</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bReplace</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t656" class="pln"><span class="n"><a href="#t656">656</a></span><span class="t">                <span class="com"># We want to replace the cog file with the output,</span>&nbsp;</span><span class="r"></span></p>
    <p id="t657" class="pln"><span class="n"><a href="#t657">657</a></span><span class="t">                <span class="com"># but only if they differ.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t658" class="mis show_mis"><span class="n"><a href="#t658">658</a></span><span class="t">                <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">verbosity</span> <span class="op">>=</span> <span class="num">2</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t659" class="mis show_mis"><span class="n"><a href="#t659">659</a></span><span class="t">                    <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">"Cogging %s"</span> <span class="op">%</span> <span class="nam">sFile</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="str">""</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t660" class="mis show_mis"><span class="n"><a href="#t660">660</a></span><span class="t">                    <span class="nam">bNeedNewline</span> <span class="op">=</span> <span class="key">True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t661" class="pln"><span class="n"><a href="#t661">661</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t662" class="mis show_mis"><span class="n"><a href="#t662">662</a></span><span class="t">                <span class="key">try</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t663" class="mis show_mis"><span class="n"><a href="#t663">663</a></span><span class="t">                    <span class="nam">fOldFile</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">openInputFile</span><span class="op">(</span><span class="nam">sFile</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t664" class="mis show_mis"><span class="n"><a href="#t664">664</a></span><span class="t">                    <span class="nam">sOldText</span> <span class="op">=</span> <span class="nam">fOldFile</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t665" class="mis show_mis"><span class="n"><a href="#t665">665</a></span><span class="t">                    <span class="nam">fOldFile</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t666" class="mis show_mis"><span class="n"><a href="#t666">666</a></span><span class="t">                    <span class="nam">sNewText</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">processString</span><span class="op">(</span><span class="nam">sOldText</span><span class="op">,</span> <span class="nam">fname</span><span class="op">=</span><span class="nam">sFile</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t667" class="mis show_mis"><span class="n"><a href="#t667">667</a></span><span class="t">                    <span class="key">if</span> <span class="nam">sOldText</span> <span class="op">!=</span> <span class="nam">sNewText</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t668" class="mis show_mis"><span class="n"><a href="#t668">668</a></span><span class="t">                        <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">verbosity</span> <span class="op">>=</span> <span class="num">1</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t669" class="mis show_mis"><span class="n"><a href="#t669">669</a></span><span class="t">                            <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">verbosity</span> <span class="op">&lt;</span> <span class="num">2</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t670" class="mis show_mis"><span class="n"><a href="#t670">670</a></span><span class="t">                                <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">"Cogging %s"</span> <span class="op">%</span> <span class="nam">sFile</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="str">""</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t671" class="mis show_mis"><span class="n"><a href="#t671">671</a></span><span class="t">                            <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">"  (changed)"</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t672" class="mis show_mis"><span class="n"><a href="#t672">672</a></span><span class="t">                            <span class="nam">bNeedNewline</span> <span class="op">=</span> <span class="key">False</span>&nbsp;</span><span class="r"></span></p>
    <p id="t673" class="mis show_mis"><span class="n"><a href="#t673">673</a></span><span class="t">                        <span class="nam">self</span><span class="op">.</span><span class="nam">replaceFile</span><span class="op">(</span><span class="nam">sFile</span><span class="op">,</span> <span class="nam">sNewText</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t674" class="pln"><span class="n"><a href="#t674">674</a></span><span class="t">                <span class="key">finally</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t675" class="pln"><span class="n"><a href="#t675">675</a></span><span class="t">                    <span class="com"># The try-finally block is so we can print a partial line</span>&nbsp;</span><span class="r"></span></p>
    <p id="t676" class="pln"><span class="n"><a href="#t676">676</a></span><span class="t">                    <span class="com"># with the name of the file, and print (changed) on the</span>&nbsp;</span><span class="r"></span></p>
    <p id="t677" class="pln"><span class="n"><a href="#t677">677</a></span><span class="t">                    <span class="com"># same line, but also make sure to break the line before</span>&nbsp;</span><span class="r"></span></p>
    <p id="t678" class="pln"><span class="n"><a href="#t678">678</a></span><span class="t">                    <span class="com"># any traceback.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t679" class="mis show_mis"><span class="n"><a href="#t679">679</a></span><span class="t">                    <span class="key">if</span> <span class="nam">bNeedNewline</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t680" class="mis show_mis"><span class="n"><a href="#t680">680</a></span><span class="t">                        <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">""</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t681" class="pln"><span class="n"><a href="#t681">681</a></span><span class="t">            <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t682" class="mis show_mis"><span class="n"><a href="#t682">682</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">processFile</span><span class="op">(</span><span class="nam">sFile</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">stdout</span><span class="op">,</span> <span class="nam">sFile</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t683" class="pln"><span class="n"><a href="#t683">683</a></span><span class="t">        <span class="key">finally</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t684" class="mis show_mis"><span class="n"><a href="#t684">684</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">restoreIncludePath</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t685" class="pln"><span class="n"><a href="#t685">685</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t686" class="run"><span class="n"><a href="#t686">686</a></span><span class="t">    <span class="key">def</span> <span class="nam">processWildcards</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sFile</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t687" class="mis show_mis"><span class="n"><a href="#t687">687</a></span><span class="t">        <span class="nam">files</span> <span class="op">=</span> <span class="nam">glob</span><span class="op">.</span><span class="nam">glob</span><span class="op">(</span><span class="nam">sFile</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t688" class="mis show_mis"><span class="n"><a href="#t688">688</a></span><span class="t">        <span class="key">if</span> <span class="nam">files</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t689" class="mis show_mis"><span class="n"><a href="#t689">689</a></span><span class="t">            <span class="key">for</span> <span class="nam">sMatchingFile</span> <span class="key">in</span> <span class="nam">files</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t690" class="mis show_mis"><span class="n"><a href="#t690">690</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">processOneFile</span><span class="op">(</span><span class="nam">sMatchingFile</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t691" class="pln"><span class="n"><a href="#t691">691</a></span><span class="t">        <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t692" class="mis show_mis"><span class="n"><a href="#t692">692</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">processOneFile</span><span class="op">(</span><span class="nam">sFile</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t693" class="pln"><span class="n"><a href="#t693">693</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t694" class="run"><span class="n"><a href="#t694">694</a></span><span class="t">    <span class="key">def</span> <span class="nam">processFileList</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">sFileList</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t695" class="pln"><span class="n"><a href="#t695">695</a></span><span class="t">        <span class="str">""" Process the files in a file list.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t696" class="pln"><span class="n"><a href="#t696">696</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t697" class="mis show_mis"><span class="n"><a href="#t697">697</a></span><span class="t">        <span class="nam">flist</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">openInputFile</span><span class="op">(</span><span class="nam">sFileList</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t698" class="mis show_mis"><span class="n"><a href="#t698">698</a></span><span class="t">        <span class="nam">lines</span> <span class="op">=</span> <span class="nam">flist</span><span class="op">.</span><span class="nam">readlines</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t699" class="mis show_mis"><span class="n"><a href="#t699">699</a></span><span class="t">        <span class="nam">flist</span><span class="op">.</span><span class="nam">close</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t700" class="mis show_mis"><span class="n"><a href="#t700">700</a></span><span class="t">        <span class="key">for</span> <span class="nam">l</span> <span class="key">in</span> <span class="nam">lines</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t701" class="pln"><span class="n"><a href="#t701">701</a></span><span class="t">            <span class="com"># Use shlex to parse the line like a shell.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t702" class="mis show_mis"><span class="n"><a href="#t702">702</a></span><span class="t">            <span class="nam">lex</span> <span class="op">=</span> <span class="nam">shlex</span><span class="op">.</span><span class="nam">shlex</span><span class="op">(</span><span class="nam">l</span><span class="op">,</span> <span class="nam">posix</span><span class="op">=</span><span class="key">True</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t703" class="mis show_mis"><span class="n"><a href="#t703">703</a></span><span class="t">            <span class="nam">lex</span><span class="op">.</span><span class="nam">whitespace_split</span> <span class="op">=</span> <span class="key">True</span>&nbsp;</span><span class="r"></span></p>
    <p id="t704" class="mis show_mis"><span class="n"><a href="#t704">704</a></span><span class="t">            <span class="nam">lex</span><span class="op">.</span><span class="nam">commenters</span> <span class="op">=</span> <span class="str">'#'</span>&nbsp;</span><span class="r"></span></p>
    <p id="t705" class="pln"><span class="n"><a href="#t705">705</a></span><span class="t">            <span class="com"># No escapes, so that backslash can be part of the path</span>&nbsp;</span><span class="r"></span></p>
    <p id="t706" class="mis show_mis"><span class="n"><a href="#t706">706</a></span><span class="t">            <span class="nam">lex</span><span class="op">.</span><span class="nam">escape</span> <span class="op">=</span> <span class="str">''</span>&nbsp;</span><span class="r"></span></p>
    <p id="t707" class="mis show_mis"><span class="n"><a href="#t707">707</a></span><span class="t">            <span class="nam">args</span> <span class="op">=</span> <span class="nam">list</span><span class="op">(</span><span class="nam">lex</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t708" class="mis show_mis"><span class="n"><a href="#t708">708</a></span><span class="t">            <span class="key">if</span> <span class="nam">args</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t709" class="mis show_mis"><span class="n"><a href="#t709">709</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">processArguments</span><span class="op">(</span><span class="nam">args</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t710" class="pln"><span class="n"><a href="#t710">710</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t711" class="run"><span class="n"><a href="#t711">711</a></span><span class="t">    <span class="key">def</span> <span class="nam">processArguments</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">args</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t712" class="pln"><span class="n"><a href="#t712">712</a></span><span class="t">        <span class="str">""" Process one command-line.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t713" class="pln"><span class="n"><a href="#t713">713</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t714" class="mis show_mis"><span class="n"><a href="#t714">714</a></span><span class="t">        <span class="nam">saved_options</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span>&nbsp;</span><span class="r"></span></p>
    <p id="t715" class="mis show_mis"><span class="n"><a href="#t715">715</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">options</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">clone</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t716" class="pln"><span class="n"><a href="#t716">716</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t717" class="mis show_mis"><span class="n"><a href="#t717">717</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="nam">args</span><span class="op">[</span><span class="num">1</span><span class="op">:</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t718" class="mis show_mis"><span class="n"><a href="#t718">718</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">validate</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t719" class="pln"><span class="n"><a href="#t719">719</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t720" class="mis show_mis"><span class="n"><a href="#t720">720</a></span><span class="t">        <span class="key">if</span> <span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span> <span class="op">==</span> <span class="str">'@'</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t721" class="mis show_mis"><span class="n"><a href="#t721">721</a></span><span class="t">            <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">sOutputName</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t722" class="mis show_mis"><span class="n"><a href="#t722">722</a></span><span class="t">                <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="str">"Can't use -o with @file"</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t723" class="mis show_mis"><span class="n"><a href="#t723">723</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">processFileList</span><span class="op">(</span><span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">1</span><span class="op">:</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t724" class="pln"><span class="n"><a href="#t724">724</a></span><span class="t">        <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t725" class="mis show_mis"><span class="n"><a href="#t725">725</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">processWildcards</span><span class="op">(</span><span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t726" class="pln"><span class="n"><a href="#t726">726</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t727" class="mis show_mis"><span class="n"><a href="#t727">727</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">options</span> <span class="op">=</span> <span class="nam">saved_options</span>&nbsp;</span><span class="r"></span></p>
    <p id="t728" class="pln"><span class="n"><a href="#t728">728</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t729" class="run"><span class="n"><a href="#t729">729</a></span><span class="t">    <span class="key">def</span> <span class="nam">callableMain</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">argv</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t730" class="pln"><span class="n"><a href="#t730">730</a></span><span class="t">        <span class="str">""" All of command-line cog, but in a callable form.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t731" class="pln"><span class="n"><a href="#t731">731</a></span><span class="t"><span class="str">            This is used by main.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t732" class="pln"><span class="n"><a href="#t732">732</a></span><span class="t"><span class="str">            argv is the equivalent of sys.argv.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t733" class="pln"><span class="n"><a href="#t733">733</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t734" class="mis show_mis"><span class="n"><a href="#t734">734</a></span><span class="t">        <span class="nam">argv</span> <span class="op">=</span> <span class="nam">argv</span><span class="op">[</span><span class="num">1</span><span class="op">:</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t735" class="pln"><span class="n"><a href="#t735">735</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t736" class="pln"><span class="n"><a href="#t736">736</a></span><span class="t">        <span class="com"># Provide help if asked for anywhere in the command line.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t737" class="mis show_mis"><span class="n"><a href="#t737">737</a></span><span class="t">        <span class="key">if</span> <span class="str">'-?'</span> <span class="key">in</span> <span class="nam">argv</span> <span class="key">or</span> <span class="str">'-h'</span> <span class="key">in</span> <span class="nam">argv</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t738" class="mis show_mis"><span class="n"><a href="#t738">738</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="nam">usage</span><span class="op">,</span> <span class="nam">end</span><span class="op">=</span><span class="str">""</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t739" class="mis show_mis"><span class="n"><a href="#t739">739</a></span><span class="t">            <span class="key">return</span>&nbsp;</span><span class="r"></span></p>
    <p id="t740" class="pln"><span class="n"><a href="#t740">740</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t741" class="mis show_mis"><span class="n"><a href="#t741">741</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">parseArgs</span><span class="op">(</span><span class="nam">argv</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t742" class="mis show_mis"><span class="n"><a href="#t742">742</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">validate</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t743" class="mis show_mis"><span class="n"><a href="#t743">743</a></span><span class="t">        <span class="nam">self</span><span class="op">.</span><span class="nam">_fixEndOutputPatterns</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t744" class="pln"><span class="n"><a href="#t744">744</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t745" class="mis show_mis"><span class="n"><a href="#t745">745</a></span><span class="t">        <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">bShowVersion</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t746" class="mis show_mis"><span class="n"><a href="#t746">746</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">prout</span><span class="op">(</span><span class="str">"Cog version %s"</span> <span class="op">%</span> <span class="nam">__version__</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t747" class="mis show_mis"><span class="n"><a href="#t747">747</a></span><span class="t">            <span class="key">return</span>&nbsp;</span><span class="r"></span></p>
    <p id="t748" class="pln"><span class="n"><a href="#t748">748</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t749" class="mis show_mis"><span class="n"><a href="#t749">749</a></span><span class="t">        <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">args</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t750" class="mis show_mis"><span class="n"><a href="#t750">750</a></span><span class="t">            <span class="key">for</span> <span class="nam">a</span> <span class="key">in</span> <span class="nam">self</span><span class="op">.</span><span class="nam">options</span><span class="op">.</span><span class="nam">args</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t751" class="mis show_mis"><span class="n"><a href="#t751">751</a></span><span class="t">                <span class="nam">self</span><span class="op">.</span><span class="nam">processArguments</span><span class="op">(</span><span class="op">[</span><span class="nam">a</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t752" class="pln"><span class="n"><a href="#t752">752</a></span><span class="t">        <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t753" class="mis show_mis"><span class="n"><a href="#t753">753</a></span><span class="t">            <span class="key">raise</span> <span class="nam">CogUsageError</span><span class="op">(</span><span class="str">"No files to process"</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t754" class="pln"><span class="n"><a href="#t754">754</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t755" class="run"><span class="n"><a href="#t755">755</a></span><span class="t">    <span class="key">def</span> <span class="nam">main</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">argv</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t756" class="pln"><span class="n"><a href="#t756">756</a></span><span class="t">        <span class="str">""" Handle the command-line execution for cog.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t757" class="pln"><span class="n"><a href="#t757">757</a></span><span class="t"><span class="str">        """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t758" class="pln"><span class="n"><a href="#t758">758</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t759" class="mis show_mis"><span class="n"><a href="#t759">759</a></span><span class="t">        <span class="key">try</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t760" class="mis show_mis"><span class="n"><a href="#t760">760</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">callableMain</span><span class="op">(</span><span class="nam">argv</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t761" class="mis show_mis"><span class="n"><a href="#t761">761</a></span><span class="t">            <span class="key">return</span> <span class="num">0</span>&nbsp;</span><span class="r"></span></p>
    <p id="t762" class="mis show_mis"><span class="n"><a href="#t762">762</a></span><span class="t">        <span class="key">except</span> <span class="nam">CogUsageError</span> <span class="key">as</span> <span class="nam">err</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t763" class="mis show_mis"><span class="n"><a href="#t763">763</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="nam">err</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t764" class="mis show_mis"><span class="n"><a href="#t764">764</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="str">"(for help use -?)"</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t765" class="mis show_mis"><span class="n"><a href="#t765">765</a></span><span class="t">            <span class="key">return</span> <span class="num">2</span>&nbsp;</span><span class="r"></span></p>
    <p id="t766" class="mis show_mis"><span class="n"><a href="#t766">766</a></span><span class="t">        <span class="key">except</span> <span class="nam">CogGeneratedError</span> <span class="key">as</span> <span class="nam">err</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t767" class="mis show_mis"><span class="n"><a href="#t767">767</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="str">"Error: %s"</span> <span class="op">%</span> <span class="nam">err</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t768" class="mis show_mis"><span class="n"><a href="#t768">768</a></span><span class="t">            <span class="key">return</span> <span class="num">3</span>&nbsp;</span><span class="r"></span></p>
    <p id="t769" class="mis show_mis"><span class="n"><a href="#t769">769</a></span><span class="t">        <span class="key">except</span> <span class="nam">CogUserException</span> <span class="key">as</span> <span class="nam">err</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t770" class="mis show_mis"><span class="n"><a href="#t770">770</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="str">"Traceback (most recent call last):"</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t771" class="mis show_mis"><span class="n"><a href="#t771">771</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="nam">err</span><span class="op">.</span><span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t772" class="mis show_mis"><span class="n"><a href="#t772">772</a></span><span class="t">            <span class="key">return</span> <span class="num">4</span>&nbsp;</span><span class="r"></span></p>
    <p id="t773" class="mis show_mis"><span class="n"><a href="#t773">773</a></span><span class="t">        <span class="key">except</span> <span class="nam">CogError</span> <span class="key">as</span> <span class="nam">err</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t774" class="mis show_mis"><span class="n"><a href="#t774">774</a></span><span class="t">            <span class="nam">self</span><span class="op">.</span><span class="nam">prerr</span><span class="op">(</span><span class="nam">err</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t775" class="mis show_mis"><span class="n"><a href="#t775">775</a></span><span class="t">            <span class="key">return</span> <span class="num">1</span>&nbsp;</span><span class="r"></span></p>
    <p id="t776" class="pln"><span class="n"><a href="#t776">776</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t777" class="pln"><span class="n"><a href="#t777">777</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t778" class="run"><span class="n"><a href="#t778">778</a></span><span class="t"><span class="key">def</span> <span class="nam">find_cog_source</span><span class="op">(</span><span class="nam">frame_summary</span><span class="op">,</span> <span class="nam">prologue</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t779" class="pln"><span class="n"><a href="#t779">779</a></span><span class="t">    <span class="str">"""Find cog source lines in a frame summary list, for printing tracebacks.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t780" class="pln"><span class="n"><a href="#t780">780</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t781" class="pln"><span class="n"><a href="#t781">781</a></span><span class="t"><span class="str">    Arguments:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t782" class="pln"><span class="n"><a href="#t782">782</a></span><span class="t"><span class="str">        frame_summary: a list of 4-item tuples, as returned by traceback.extract_tb.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t783" class="pln"><span class="n"><a href="#t783">783</a></span><span class="t"><span class="str">        prologue: the text of the code prologue.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t784" class="pln"><span class="n"><a href="#t784">784</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t785" class="pln"><span class="n"><a href="#t785">785</a></span><span class="t"><span class="str">    Returns</span>&nbsp;</span><span class="r"></span></p>
    <p id="t786" class="pln"><span class="n"><a href="#t786">786</a></span><span class="t"><span class="str">        A list of 4-item tuples, updated to correct the cog entries.</span>&nbsp;</span><span class="r"></span></p>
    <p id="t787" class="pln"><span class="n"><a href="#t787">787</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t788" class="pln"><span class="n"><a href="#t788">788</a></span><span class="t"><span class="str">    """</span>&nbsp;</span><span class="r"></span></p>
    <p id="t789" class="run"><span class="n"><a href="#t789">789</a></span><span class="t">    <span class="nam">prolines</span> <span class="op">=</span> <span class="nam">prologue</span><span class="op">.</span><span class="nam">splitlines</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t790" class="run"><span class="n"><a href="#t790">790</a></span><span class="t">    <span class="key">for</span> <span class="nam">filename</span><span class="op">,</span> <span class="nam">lineno</span><span class="op">,</span> <span class="nam">funcname</span><span class="op">,</span> <span class="nam">source</span> <span class="key">in</span> <span class="nam">frame_summary</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t791" class="par run show_par"><span class="n"><a href="#t791">791</a></span><span class="t">        <span class="key">if</span> <span class="key">not</span> <span class="nam">source</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">791&#x202F;&#x219B;&#x202F;803</span><span class="annotate long">line 791 didn't jump to line 803, because the condition on line 791 was never false</span></span></p>
    <p id="t792" class="run"><span class="n"><a href="#t792">792</a></span><span class="t">            <span class="nam">m</span> <span class="op">=</span> <span class="nam">re</span><span class="op">.</span><span class="nam">search</span><span class="op">(</span><span class="str">r"^&lt;cog ([^:]+):(\d+)>$"</span><span class="op">,</span> <span class="nam">filename</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t793" class="par run show_par"><span class="n"><a href="#t793">793</a></span><span class="t">            <span class="key">if</span> <span class="nam">m</span><span class="op">:</span>&nbsp;</span><span class="r"><span class="annotate short">793&#x202F;&#x219B;&#x202F;794</span><span class="annotate long">line 793 didn't jump to line 794, because the condition on line 793 was never true</span></span></p>
    <p id="t794" class="mis show_mis"><span class="n"><a href="#t794">794</a></span><span class="t">                <span class="key">if</span> <span class="nam">lineno</span> <span class="op">&lt;=</span> <span class="nam">len</span><span class="op">(</span><span class="nam">prolines</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t795" class="mis show_mis"><span class="n"><a href="#t795">795</a></span><span class="t">                    <span class="nam">filename</span> <span class="op">=</span> <span class="str">'&lt;prologue>'</span>&nbsp;</span><span class="r"></span></p>
    <p id="t796" class="mis show_mis"><span class="n"><a href="#t796">796</a></span><span class="t">                    <span class="nam">source</span> <span class="op">=</span> <span class="nam">prolines</span><span class="op">[</span><span class="nam">lineno</span><span class="op">-</span><span class="num">1</span><span class="op">]</span>&nbsp;</span><span class="r"></span></p>
    <p id="t797" class="mis show_mis"><span class="n"><a href="#t797">797</a></span><span class="t">                    <span class="nam">lineno</span> <span class="op">-=</span> <span class="num">1</span>     <span class="com"># Because "import cog" is the first line in the prologue</span>&nbsp;</span><span class="r"></span></p>
    <p id="t798" class="pln"><span class="n"><a href="#t798">798</a></span><span class="t">                <span class="key">else</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t799" class="mis show_mis"><span class="n"><a href="#t799">799</a></span><span class="t">                    <span class="nam">filename</span><span class="op">,</span> <span class="nam">coglineno</span> <span class="op">=</span> <span class="nam">m</span><span class="op">.</span><span class="nam">groups</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t800" class="mis show_mis"><span class="n"><a href="#t800">800</a></span><span class="t">                    <span class="nam">coglineno</span> <span class="op">=</span> <span class="nam">int</span><span class="op">(</span><span class="nam">coglineno</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t801" class="mis show_mis"><span class="n"><a href="#t801">801</a></span><span class="t">                    <span class="nam">lineno</span> <span class="op">+=</span> <span class="nam">coglineno</span> <span class="op">-</span> <span class="nam">len</span><span class="op">(</span><span class="nam">prolines</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t802" class="mis show_mis"><span class="n"><a href="#t802">802</a></span><span class="t">                    <span class="nam">source</span> <span class="op">=</span> <span class="nam">linecache</span><span class="op">.</span><span class="nam">getline</span><span class="op">(</span><span class="nam">filename</span><span class="op">,</span> <span class="nam">lineno</span><span class="op">)</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
    <p id="t803" class="run"><span class="n"><a href="#t803">803</a></span><span class="t">        <span class="key">yield</span> <span class="nam">filename</span><span class="op">,</span> <span class="nam">lineno</span><span class="op">,</span> <span class="nam">funcname</span><span class="op">,</span> <span class="nam">source</span>&nbsp;</span><span class="r"></span></p>
    <p id="t804" class="pln"><span class="n"><a href="#t804">804</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t805" class="pln"><span class="n"><a href="#t805">805</a></span><span class="t">&nbsp;</span><span class="r"></span></p>
    <p id="t806" class="run"><span class="n"><a href="#t806">806</a></span><span class="t"><span class="key">def</span> <span class="nam">main</span><span class="op">(</span><span class="op">)</span><span class="op">:</span>&nbsp;</span><span class="r"></span></p>
    <p id="t807" class="pln"><span class="n"><a href="#t807">807</a></span><span class="t">    <span class="str">"""Main function for entry_points to use."""</span>&nbsp;</span><span class="r"></span></p>
    <p id="t808" class="mis show_mis"><span class="n"><a href="#t808">808</a></span><span class="t">    <span class="key">return</span> <span class="nam">Cog</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">main</span><span class="op">(</span><span class="nam">sys</span><span class="op">.</span><span class="nam">argv</span><span class="op">)</span>&nbsp;</span><span class="r"></span></p>
</div>
<div id="footer">
    <div class="content">
        <p>
            <a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v5.3</a>,
            created at 2020-09-13 15:56 -0400
        </p>
    </div>
</div>
</body>
</html>
